System.out.print("My string: ");
My string: BUILD SUCCESSFUL (total time: 1 second)
System.out.print("My string ");
My string BUILD SUCCESSFUL (total time: 1 second)
System.out.print("My string: ");
My string: 开发者_开发知识库My string:
BUILD SUCCESSFUL (total time: 1 second)Printing a string that ends with a colon and two spaces will make it print twice. What is happening here?
Edit: looks like it's a bug in Netbeans indeed
http://netbeans.org/bugzilla/show_bug.cgi?id=167279
I think the output stream's buffering is making you interpret what you see wrongly. Try using println()
.
I noticed that behavior on Netbeans, when running JUnit tests. It that also your case? Seems to be just a bug.
Which java version do you have? It doesn't happen in 1.6.0_16
Are you sure it's not some danging lines in the unix shell (if you're on unix)?. Try with System.out.println("My string: ");
精彩评论