Tutorials for Java ,Core java ,Advance java ,oracle ,HTML, CSS, JavaScript, Java and other programming language tutorial Learn Java tutorial for beginners with examples in eclipse online. Java tutorial point for core java, servlet, jsp, struts, spring, for learning web technologies online. Content includes tutorials and references relating to HTML, CSS, JavaScript, PHP, AngularJS, SQL, Bootstrap, Node.js, and jQuery this is a website like w3school tutorialspoint etc

Search This Blog

About

Header Ads

Friday, 2 March 2018

Difference between Print() and Println() Methods ?

0 comments

Difference between Print() and Println() Methods ?


Print() method will displaying given value in the same line and places cursor in the same so that the next coming value  will be also displayed in the same line .


where as println method will display the  value in same line the moves cursor to next line . so that the next displaying value will be printed in the next line .

the "ln" property is applicable in next displaying values but not on current displaying value .

hence we must choose either print() or println() method depending on the next  value printing line .

if we want print both current value  and next value in the same line , we must  display current value by using print () method .

if we want to print current value and next value in different lines we must display current value by using println () method .

Question-Develop a program to display the below 5 statements in 3 line as shown in the below pattern .

input                  Output
                                              
A                        A, B
B
C                       C, D
D                        E
E      

Program-

New javaprogram.java

Class javaprogram{
      
public static void args(String[]args){
        System..out.print("A");
         System..out.println("B");
          System.out.print("C");
            System.out.println("D");
               System.out.print("E");
      }
}                     

No comments:

Post a Comment