System.out.println (“”);
• This statement is used for displaying the data or messages on to the consol (monitor).
• Here, println is the predefined instance method of print stream class.
• To call this method we require an object called print stream class.
• The object of print stream class is called out is created as a static data member in system
class (system is a predefined class).
• Hence to call the println method we must use the following statement:
System.out.println (“WELCOME TO JAVA”);
• Print stream class is a predefined class which contains nine overloaded instance println
methods and nine overloaded instance print methods and whose prototypes are as follows:
Public void println (byte);
Public void println (short);
Public void println (int);
Public void println (long);
Public void println (float);
Public void println (double);
Public void println (char);
Public void println (Boolean);
Public void println (string);
Public void print (byte);
Public void print (short);
Public void print (int);
Public void print (long);
Public void print (float);
Public void print (double);
Public void print (char);
Public void print (Boolean);
Public void print (string);
For example 1:
Int a=40000;
System.out.println (a); //40000
System.out.println (“value of a=” + a); //value of a=40000
System.out.println (a + “is the value of a”); //40000 is the value of a
For example 2:
Int a=10, b=20, c;
C = a + b;
System.out.println (c); //30
System.out.println (“sum=” + c); //sum=30
System.out.println (c + “is the sum”); // 30 is the sum
System.out.println (“sum of” + a + “and” + b + “=” + c); //sum of 10 and 20 is 30
For example 3:
System.out.println (“WELCOME TO JAVA”);
• This statement is used for displaying the data or messages on to the consol (monitor).
• Here, println is the predefined instance method of print stream class.
• To call this method we require an object called print stream class.
• The object of print stream class is called out is created as a static data member in system
class (system is a predefined class).
• Hence to call the println method we must use the following statement:
System.out.println (“WELCOME TO JAVA”);
• Print stream class is a predefined class which contains nine overloaded instance println
methods and nine overloaded instance print methods and whose prototypes are as follows:
Public void println (byte);
Public void println (short);
Public void println (int);
Public void println (long);
Public void println (float);
Public void println (double);
Public void println (char);
Public void println (Boolean);
Public void println (string);
Public void print (byte);
Public void print (short);
Public void print (int);
Public void print (long);
Public void print (float);
Public void print (double);
Public void print (char);
Public void print (Boolean);
Public void print (string);
For example 1:
Int a=40000;
System.out.println (a); //40000
System.out.println (“value of a=” + a); //value of a=40000
System.out.println (a + “is the value of a”); //40000 is the value of a
For example 2:
Int a=10, b=20, c;
C = a + b;
System.out.println (c); //30
System.out.println (“sum=” + c); //sum=30
System.out.println (c + “is the sum”); // 30 is the sum
System.out.println (“sum of” + a + “and” + b + “=” + c); //sum of 10 and 20 is 30
For example 3:
System.out.println (“WELCOME TO JAVA”);
0 comments:
Post a Comment