Rather than go through that trouble, just compare the input to see if equals "q" (or 'q', depending on how you're obtaining the input).I thought about transforming a string input to a integer...
desirednumber = Integer.valueOf(String Userinput)
Is that about right??
Nice catch - I overlooked that completely. On a side note, is depending on the NFE exception message for evaluating user input a good idea?P.S. You had the "String" type inside of your code example:
Integer.parseInt(String inputVal)
which is incorrect -- when CALLING a method such as parseInt, you don't specify the type of the argument you are passing; you only declare the type of a parameter when the method is declared (something that, in this case, happens for you within the Integer class).
Originally posted by Daniel Ryan:
i thoght it was initialised temp = Integer.parseInt(t)..etc....
Compile it. Write a test case. Fix the code as necessary (such as not using the == operator to compare String objects) until you get it working the way you want it to. Then, work on fixing the design.so tell me how close is this?
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |