Difference of print and println - Lesson 2

Echoing words in Java
 Now i'm going to describe difference of print and println

Fist i use println 

class Example2{
       public static void main(String args[]){
           System.out.
println("Hello Java");
           System.out.
println("Hello Java");
           System.out.
println("Hello Java");
           System.out.
println("Hello Java");
           System.out.
println("Hello Java");
           System.out.
println("Hello Java");
       }
   }


Out put Is :-

Hello Java
Hello Java
Hello Java
Hello Java
Hello Java
Hello Java   

When i used println Out put print in line by line.


And print

class Example2{
       public static void main(String args[]){
           System.out.
print("Hello Java");
           System.out.
print("Hello Java");
           System.out.
print("Hello Java");
           System.out.
print("Hello Java");
           System.out.
print("Hello Java");
           System.out.
print("Hello Java");
       }
   }


Out put Is :-

Hello JavaHello JavaHello JavaHello JavaHello JavaHello Java

If i use print out put print in same line

   

That is difference of println and print and i think you can understand difference of println and print.

This entry was posted on Thursday, November 29, 2012 and is filed under ,. You can follow any responses to this entry through the RSS 2.0. You can leave a response.

Leave a Reply

Powered by Blogger.