If you find yourself using too much System.out.println("something") a lot, here is a savior, it got into my head deep down the first time I clamped my eyes on this beast:
public class SomeClass{
private methodName1(params){
doSomething();
log("print whatever on console...");
}
}
public methodName2(params){
log("print waterver2 on console...");
}
}
private static void log(String aMessage){
System.out.println(aMessage);
}
}
---------------
so just using
private static void log(String aMessage){
System.out.println(aMessage);
}
at one place, you can replace all your System.out.println() statements by simply this:
log("some message");
Saves a lot of time and space.
cheers,
~nirmal
Monday, July 27, 2009
Sunday, July 26, 2009
Math.Random()
math.random() generates a number between 0 and 1. If you do *X(x=any integer), it changes the math.random() to 0-9, then you can do +1 to change it to 1-10.
Eg. For generating random values in the range 35 - 55, look at the following example:
Math.floor((math.random() * 35) + 55)
~nirmal
Eg. For generating random values in the range 35 - 55, look at the following example:
Math.floor((math.random() * 35) + 55)
~nirmal
Subscribe to:
Comments (Atom)