Java Reference
In-Depth Information
System.out.println(randomElement(a));
}
private static Random rnd = new Random();
private static String randomElement(String[] a) {
return a[rnd.nextInt(a.length)];
}
}
To summarize: First, be careful of fencepost errors. Second, remember to put a break after each
case in switch statements. Third, use common idioms and APIs, and consult the documentation
when you stray from the well-worn path. Fourth, a char is not a String but is more like an int .
Finally, watch out for sneaky puzzlers.
< Day Day Up >
 
 
Search WWH ::




Custom Search