User Profile
Collapse
-
All the GUI classes extend Component, so you can use the getWidth() and getHeight() methods to find the current dimensions of a frame or window. -
showInputDialog () returns null when you click cancel so just check if strChoice is null before continuing. You also need to call exit() in case 4. The way you have it now because there is no break in case 4 it continues on to the default case and displays the "Wrong!!", "WAAAY OFF!!!" message. You get a NullPointerExce ption when you enter 3 because you set strTryDouble to null then tried to parse a double from it. I'm not sure...Leave a comment:
-
java.util.Rando m handles random numbers in Java:
Check out the API for more info....Code:Random rand = new Random() int aRandomInt = rand.nextInt(10) // Random int 0 (inclusive) to 10 (exclusive)
Leave a comment:
-
reverse() reverses the order of the characters in the StringBuffer, so it will do what you're looking for.
This would print:Code:StringBuffer str = new StringBuffer("This is a string"); System.out.println(str); str.reverse(); System.out.println(str);
Code:This is a string gnirts a si sihT
Leave a comment:
No activity results to display
Show More
Leave a comment: