Reputation: 11
When running this in a command prompt,
System.out.println(Num + " is prime!");
System.out.println("Press N to put in another number or S to stop");
Where Num
is an int
This is what comes out:
Is there any way to counter it or should I just deal with it?
Upvotes: 1
Views: 1152
Reputation: 1527
System.out.println(String.valueOf(Num) + " is prime!");
Edit: Adding more information to replete the mystery here.
java.lang.String.valueOf will correctly parse your Number where as simply adding a Number with a String will vary between compilers.
See more here Concat an integer to a String - use String literal or primitive from performance and memory point of view?
Upvotes: 1