Friday, October 11, 2013

Print statements

print Statement 

There are three kind of print statements 
  1. System.out.print(Argument);
  2. System.out.println(Argument);
  3. System.out.printf(format , Argument);


print and println

Type this code and See the out put

public class PrintStatement {
    
    public static void main(String[] args) {
        System.out.print("One , ");
        System.out.print("Two , ");
        System.out.print("Three , ");
        
    }
    
}




The Out put is  One , Two , Three ,
The print("One") method instead prints just the One , but does not move the cursor to a new line
Now open your .java file and change your code like this and save and see the out put

class PrintStatement {
    
    public static void main(String[] args) {
        System.out.println("One , ");
        System.out.println("Two , ");
        System.out.println("Three , ");
        
    }
    
}

The Out put is 
One , 
Two , 
Three ,




The Diferent of print and println is 
The println("") method prints the string "" and moves the cursor to a new line. The print("") method instead prints just the string "", but does not move the cursor to a new line. Hence, subsequent printing instructions will print on the same line. The println() method can also be used without parameters, to position the cursor on the next line
a



Insurance Loans Mortgage Attorney Credit Lawyer Donate Degree Hosting Claim Conference Call Trading Software Recovery Transfer Gas/Electricity Classes Rehab Treatment Cord Blood

No comments:

Post a Comment