This life is here for a reason, we don’t have to say exactly what that reason is, we just have to believe in it no matter what happens in this life, we have to understand one thing. That thing is that we are not alone in the universe. I’m not saying there are aliens out there, but yeah there are aliens out there. It’s a concept that people have wondered about from time to time, there doesn’t appear to be anything else you can do but wonder what’s going on in the skies above us! There are so many things in this life that don’t always seem to matter, but you wish they would, at least that’s what I’d like to think would happen. I’m not sure that’s how this life is meant to be understood of course. If there’s anything in this life that doesn’t make sense, then it will always be there. It doesn’t have to make sense, that’s the absurdity of it all! Why should it make sense if there’s nothing to grasp from it all? I’m not sure I know the ansewr to that question. Such a life comes and goes an...
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