The Java else if
[-]
2-4-2009
Long time, no update, but whatever...
I was thinking the other day about the "else if" condition. Normally, you would see it like this:
But here is another interesting way to look at it:
I was thinking the other day about the "else if" condition. Normally, you would see it like this:
int number = (int)(Math.random() * 5);
if (number == 0)
{
System.out.println("The number is zero.");
}
else if (number == 1)
{
System.out.println("The number is one.");
}
else if (number == 2)
{
System.out.println("The number is two.");
}
But here is another interesting way to look at it:
int number = (int)(Math.random() * 5);
if (number == 0)
{
System.out.println("The number is zero.");
}
else
{
if (number == 1)
{
System.out.println("The number is one.");
}
else
{
if (number == 2)
{
System.out.println("The number is two.");
}
}
}
10-29-2008
Sometimes, when writing inner classes, you'll want to access the outer class' variables or methods from the inner class. This can be easily done by simply refering to that variable/method like you normally would, as if you weren't in an inner class.
But sometimes, you'll want a reference the outer class object to which the inner class belongs. Simply using
Other times, you might override variable names or method signatures in the inner class, and you'll want to access those elements of the outer class. Or maybe you just want to be explicit about what you're accessing. This is really simple.
Take the following class for example:
If you were to run the following lines of code
you would get the following output:
Note that you can access three different variable of the same name, by using
But sometimes, you'll want a reference the outer class object to which the inner class belongs. Simply using
this won't work, as this refers to the inner class object. In this case you need to use OuterClassName.this.Other times, you might override variable names or method signatures in the inner class, and you'll want to access those elements of the outer class. Or maybe you just want to be explicit about what you're accessing. This is really simple.
Take the following class for example:
public class OuterClass
{
String variable = "I'm from the outer class";
public class InnerClass
{
String variable = "I'm from the inner class";
public void printVariables()
{
String variable = "I'm from the printVariables() method";
System.out.println(OuterClass.this.variable);
System.out.println(this.variable);
System.out.println(variable);
}
}
}
If you were to run the following lines of code
OuterClass outer = new OuterClass();
InnerClass inner = outer.new InnerClass();
inner.printVariables();you would get the following output:
I'm from the outer class
I'm from the inner class
I'm from the printVariables() methodNote that you can access three different variable of the same name, by using
TheOuterClassName.this and this.10-12-2008
Recently, as you may have noticed, there were some major hardware failures with the T35 which hosts my website. More info here.
The result of these hardware failures is that all data that was stored on the server (i.e. my entire website) was lost. Unfortunately, I hadn't made a back-up of my site in almost a year. So, a lot of the changes I've made were lost for good.
Fortunately, I switched to using a MySQL database to store my blog entries a while back. And that databases is hosted by a different service so all that content is perfectly intact.
I'll be working on rebuilding the site, when I have some spare time, which isn't all that often nowadays.
The result of these hardware failures is that all data that was stored on the server (i.e. my entire website) was lost. Unfortunately, I hadn't made a back-up of my site in almost a year. So, a lot of the changes I've made were lost for good.
Fortunately, I switched to using a MySQL database to store my blog entries a while back. And that databases is hosted by a different service so all that content is perfectly intact.
I'll be working on rebuilding the site, when I have some spare time, which isn't all that often nowadays.
9-11-2008
Flickr user SA_Steve uploaded the following photos to the hilarious Stick Figures in Peril Group.

For each of the four photos, here is what I can interpret as the meaning.
Maybe I'm missing something?

For each of the four photos, here is what I can interpret as the meaning.
- Do not let black children ride on the lawn mower.
- Instead, ride the mower over some rocks such that you pelt the child's parent in the face.
- Then proceed to run over the child's leg with the mower.
- Finally, run over the child's other leg.
Maybe I'm missing something?
7-19-2008
I just added a page to this website that lists the thumbnails for all the photos in my Flickr account. You can see it by clicking the 'Photos' link in the navigation bar on the left side of most pages.
The photo page makes heavy use of phpFlickr, a wrapper for Flickr's API, written in PHP, by Dan Coulter. (Thanks Dan!) And with a little bit of Javascript and CSS, I added some effects when you hover your mouse over a thumbnail. Clicking the thumbnail will take to you to the flickr page for that photo, where you can view larger versions, leave a comment, among other things.
The php code for listing the images is pretty straightfoward, besides the classes included with phpFlickr; a lot of that is over my head; But using phpFlickr is really very simple.
The photo page makes heavy use of phpFlickr, a wrapper for Flickr's API, written in PHP, by Dan Coulter. (Thanks Dan!) And with a little bit of Javascript and CSS, I added some effects when you hover your mouse over a thumbnail. Clicking the thumbnail will take to you to the flickr page for that photo, where you can view larger versions, leave a comment, among other things.
The php code for listing the images is pretty straightfoward, besides the classes included with phpFlickr; a lot of that is over my head; But using phpFlickr is really very simple.
Wipeout
[-]
7-8-2008
Recently a new show aired on ABC called Wipeout. I watched it for the first time tonight. It didn't quite meet my expectations...
Going in, I was expecting a show that was sort of an amalgam of Ninja Warrior and Most Extreme Elimination Challenge (MXC). I was disappointed, however. The show seems to be more like an American twist on MXC, with more sophisticated obstacles and hosts.
I was hoping for something like Ninja Warrior, with some emphisis on the contestants' physical ability and talent. However this show seems to focus more on making the contestant fail the obstacles, hence the name "Wipeout." Nearly all the obstacles are all designed to make the contestant fall into the mud/water; and a lot of the contestants don't seem like they should be anywhere near an obstacle course. But worst of all, failing any/all of the obstacle doesn't eliminate you! You just have to climb back up to the obstacle and reattempt it until you get past it or in the first course, they advance to the next obstacle. Eliminations are determined by the time it takes you to finish the course, and in some cases, who finishes first, because at times, the contestants all go through the course at once.
The obstacle courses were pretty lame as well. For example, the first course had like four obstacles: A series of stacked tire innertubes, a ledge next to a wall that has arms punch out at seemingly random intervals, a series of large inflatable balls that the contestants jump from on to another, and a "pole vault" which is basically just a pole that the contestants use to vault in to the water and then swim to the last platform. Nobody completely passed all the obstacles, and about 90% didn't pass any of them, and thus half of the time the contestant was in the mud/water.
Overall, a disappointment.
Going in, I was expecting a show that was sort of an amalgam of Ninja Warrior and Most Extreme Elimination Challenge (MXC). I was disappointed, however. The show seems to be more like an American twist on MXC, with more sophisticated obstacles and hosts.
I was hoping for something like Ninja Warrior, with some emphisis on the contestants' physical ability and talent. However this show seems to focus more on making the contestant fail the obstacles, hence the name "Wipeout." Nearly all the obstacles are all designed to make the contestant fall into the mud/water; and a lot of the contestants don't seem like they should be anywhere near an obstacle course. But worst of all, failing any/all of the obstacle doesn't eliminate you! You just have to climb back up to the obstacle and reattempt it until you get past it or in the first course, they advance to the next obstacle. Eliminations are determined by the time it takes you to finish the course, and in some cases, who finishes first, because at times, the contestants all go through the course at once.
The obstacle courses were pretty lame as well. For example, the first course had like four obstacles: A series of stacked tire innertubes, a ledge next to a wall that has arms punch out at seemingly random intervals, a series of large inflatable balls that the contestants jump from on to another, and a "pole vault" which is basically just a pole that the contestants use to vault in to the water and then swim to the last platform. Nobody completely passed all the obstacles, and about 90% didn't pass any of them, and thus half of the time the contestant was in the mud/water.
Overall, a disappointment.
| History | ||||||
|---|---|---|---|---|---|---|
| 2005 | September | October | November | December | ||
| 2006 | January | February | March | April | May | June |
| July | August | September | October | November | December | |
| 2007 | January | February | March | April | May | June |
| July | August | September | October | November | December | |
| 2008 | January | February | March | April | May | June |
| July | August | September | October | |||
| Terms Of Use | About Me | Contact |
Content © 2008 AJ Marx
Site design based on Cameron Hunt's Mac Envy Tumblr theme.