Sign in to follow this  
chetanaforum

What is 'System', 'out', 'println' in System.out.println


Dear Chetanaites,

I am starting the discussion with a basic question on JAVA. Write your answers for this. Feel free to discuss. Try to be clear in your explanation. I will try to post few questions everyday that are asked in various company J2EE interviews. However I am not that good technically. So it's up to you to be active, discuss & clarify your doubts, reply to others, help them etc. Lets grow together.

If you have any other JAVA/J2EE questions, open a new thread and post it. Lets improve ourselves technically.

Question of the Day :- 18 March 2006

----------------------------------------------------------------

What is "System", "out", "println" in System.out.println ? Explain !

----------------------------------------------------------------

Share this post


Link to post
Share on other sites

Dear Chetanaites,

I am starting the discussion with a basic question on JAVA. Write your answers for this. Feel free to discuss. Try to be clear in your explanation.

If you have any other JAVA/J2EE questions, open a new thread and post it. Lets improve ourselves technically.

Question of the Day :- 18 March 2006

----------------------------------------------------------------

What is "System", "out", "println" in System.out.println ? Explain !

----------------------------------------------------------------

System is a predefined class that provides acess to the system.

out is the outputstream that is connected to the console.

println() - Displays the String which is passed to it.

Share this post


Link to post
Share on other sites

System.out.println()

System is a built-in class present in java.lang package.

This class has a final modifier, which means that, it cannot be inherited by other classes.

It contains pre-defined methods and fields, which provides facilities like standard input, output, etc.

out is a static final field (ie, variable)in System class which is of the type PrintStream (a built-in class, contains methods to print the different data values).

static fields and methods must be accessed by using the class name, so ( System.out ).

out here denotes the reference variable of the type PrintStream class.

println() is a public method in PrintStream class to print the data values.

Hence to access a method in PrintStream class, we use out.println() (as non static methods and fields can only be accessed by using the refrence varialble)

System.out.println();

eg:

int i = 3;

System.out.println(i);

the above code prints the value of 3 in the screen and brings the control to the next line.

Share this post


Link to post
Share on other sites

All java programs automatically import java.lang package.This package defines a class called System.The System class holds a collection of static methods and variables.the standard input,output and error output of the java runtime are stored in in,out,err variables.

Some of the methods of System Class are:

static long currentTimeMillis() - Return the current time in terms of milliseconds.

ex:

long timeinsec = System.currentTimeMillis();

static String getProperty(String prop) - Returns the property associated with prop.

ex:

class displayuserdir

{

public static void main(String a[])

{

System.out.println(System.getProperty("user.dir"));

}

}

Share this post


Link to post
Share on other sites

Hi!I am new to the site, still upto my knowledge System is a class,Out is an object & Println is the method that sends the text or anything in it to the standard output device like monitor with a new line feed.More discussion is possible if other threads come!Thanks

Share this post


Link to post
Share on other sites

 

QUOTE (ChetanaS @ Mar 18 2006, 12:08 AM) <{POST_SNAPBACK}>
Dear Chetanaites,

I am starting the discussion with a basic question on JAVA. Write your answers for this. Feel free to discuss. Try to be clear in your explanation.

 

If you have any other JAVA/J2EE questions, open a new thread and post it. Lets improve ourselves technically.

 

Question of the Day :- 18 March 2006

----------------------------------------------------------------

What is "System", "out", "println" in System.out.println ? Explain !

----------------------------------------------------------------

System is a predefined class that provides acess to the system.

out is the outputstream that is connected to the console.

println() - Displays the String which is passed to it.

 

yeah in short you are right .i spend a half day to understand it and finaly had a postmortem of SOP in my blog http://javatuts24.blogspot.in/2013/07/what-is-system-and-out-in.html

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this