New concepts: most of you are probably unfamiliar with the following: 1. Command line arguments. When you invoke a java program from the command line, there is the option of passing it a series of arguments separated by spaces, as in java programname 2 3 hello The arguments are passed to main as an array of strings, which explains: public static void main(String[] args) For example, args[1] would be "3". To extract the integer value from the string representation, use int x = Integer.parseInt(args[1]); 2. A method (function) can be declared static if it's independent of any instance variables inside a class. In other words, if all information required by the function are passed in as parameters, then the function should be declared static. Static functions can only refer to other class members that are also static. Here's another way to remember the proper usage of static: If f is a static function of class C and a and b are instances of class C, then a.f(...) and b.f(...) should always be the same, because f is independent of any particular instance of the class. It is infact better to call C.f(...) instead. static functions are also called "class functions" for this reason. 3. Exceptions. Exceptions are special objects that are "thrown" when unexpected events occur - such as division by zero. Here's a function that may throw an exception (it sees if b evenly divides a) public static boolean evenlydiv(int a, int b) throws Exception { if (b==0) throw new Exception("can't divide by zero"); else return (a%b == 0); } Now, when you call this function, you must enclose it in a "try-catch" clause: try { // code that may throw exceptions // such as ... evenlydiv(3,0) ... } catch Exception(e) { System.exit(1); } The code inside the {}'s after the "catch" is the code that will be executed if an exception is thrown. System.exit(1) terminates the program with an error. Exceptions should only be used if normal programming devices cannot be used. Do not use exceptions instead of if-else statements if the later work just as well. Use exceptions only for dealing with situations that cannot be anticipated.