CaptainKirk55
CaptainKirk55

Reputation: 11

Question Mark in a Box when using println

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?

Upvotes: 1

Views: 1152

Answers (1)

Robert I
Robert I

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

Related Questions