- Joined
- Jul 25, 2008
- Sythe Gold
- 0
- Messages
- 902
Hello everybody, I know there are some new users of Java here reading this, and I am sure they have take a look at a line of code and seen:
and
and were probably like wtf? Am I right? Well, today I am going to clear up the difference of print, and println for the new users. Okay, lets say you have a code such as:
but when you go to compile and run it, it will all be on the same line. and your like wtf? How do I get it to the next line? Well that is where println comes in.
Println stands for Print line, So if you were to write that same line of code above with println instead of print, it would come out such as:
It would appear as this with println:
Whereas print would show:
You do not need to add println on the last sentence though, notice how I added it in the Hello how are you line, but not in the I am doing fine line? That is because when you use println, it only makes the next print out drop to the next line.
So if we had:
It would read:
Because println was on the second line, instead of the first. It always needs to be above the line you want to drop down.
Well, I hope this cleared some stuff up for new users to Java. Thank you guys.
~~ Diabl0
System.out.print("Whatever");
and
System.out.println("Whatever");
and were probably like wtf? Am I right? Well, today I am going to clear up the difference of print, and println for the new users. Okay, lets say you have a code such as:
System.out.print("Hello how are you");
System.out.print("I am doing fine");
but when you go to compile and run it, it will all be on the same line. and your like wtf? How do I get it to the next line? Well that is where println comes in.
Println stands for Print line, So if you were to write that same line of code above with println instead of print, it would come out such as:
System.out.println("Hello how are you");
System.out.print("I am doing fine");
It would appear as this with println:
"Hello how are you
I am doing fine"
Whereas print would show:
"Hello how are youI am doing fine"
You do not need to add println on the last sentence though, notice how I added it in the Hello how are you line, but not in the I am doing fine line? That is because when you use println, it only makes the next print out drop to the next line.
So if we had:
System.out.print("Hello how are you");
System.out.println("I am doing fine");
It would read:
Hello how are youI am doing fine.
Because println was on the second line, instead of the first. It always needs to be above the line you want to drop down.
Well, I hope this cleared some stuff up for new users to Java. Thank you guys.
~~ Diabl0


