Legion Daeth Legion Daeth - 10 months ago 59
Java Question

println overtypes first argument

Sorry about the basic question, I'm still very new to Java.

When I try to use

to print a
variable followed by a colon the colon overtypes the first letter of the

So for example I type the following command

System.out.println(planetName + ":");

...and get this as output (Lets say the planet name is Zeta Alpha II)

:eta Alpha II

What am I doing wrong? If I omit the colon then the variable prints normally. Everything else works fine, I have tried
solutions and using a
variable to no avail also.

ANSWER: As JimGarrison was so kind to suggest in the comments, the input file had \r characters (i.e. it was in CRLF DOS \r\n format.), a quick run of
fixed the input data and solved the problem

Answer Source

The input file is in DOS format with each line ending with \r\n.

Remove the \r with a Dos-to-Unix utility such as dos2unix