1

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:

This is what comes out

Is there any way to counter it or should I just deal with it?

1 Answers1

1
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?

Robert I
  • 1,509
  • 2
  • 11
  • 18