Life always has a way of doing whatever it needs to do. There’s nothing wrong with that thought process. It comes and goes without a second thought. We can’t easily figure out why life does this to us, we have to understand something at some point, but if we don’t? Well, no harm no foul. It’s life and we have to continue going forward to see everything that is out there. There’s nothing we can do about it. Life will move foreward without the ability for us to do anything but wonder what this life will eventually be like in the far distant future. Oh what a joy that could bring about. If life has a way, we will be able to get from point a to point b in no time at all. It feels like a circle at times. A = B = C, isn’t that what the crazy future guy in Star Trek: Voyager tried to explain? Yeah, something like that. It’s quite an interesting thought process to be sure. It’s life though, nothing can be done about it. So let life be what it wants to be, there’s nothing wrong with that tho...
Sometimes you want to be able to check if a number is odd or even. Here's a simple method that will do just that.
public class OddOrEven {
public static void main(String[] args) {
int i = Integer.valueOf(args[0]);
System.out.println(oddOrEven(i));
}
public static String oddOrEven(int number) {
if (number %2 == 0) {
return "Even";
} else {
return "Odd";
}
}
}
Naturally you'll want to do some value checking for the number input at the command line. It could easily throw an InvalidNumberFormat exception. I think that's the exception that would be thrown.
Comments
Post a Comment