What is System.out.println in java
What is System in java ?
The System is a predefined class. Which is present in java. lang package.
- The System class is a final class and do not provide any public constructors. Because of this all of the members are methods contained in this class are static in nature.
- The System class also provides facilities like standard input, standard output, and error output Streams. it can't be instantiated.
public static final java.io.InputStream in;
public static final java.io.PrintStream out;
public static final java.io.PrintStream err;
public static void setIn(java.io.InputStream);
public static void setOut(java.io.PrintStream);
public static void setErr(java.io.PrintStream);
public static java.io.Console console();
public static java.nio.channels.Channel inheritedChannel() throws java.io.IOException;
public static void setSecurityManager(java.lang.SecurityManager);
public static java.lang.SecurityManager getSecurityManager();
public static native long currentTimeMillis();
public static native long nanoTime();
public static native void arraycopy(java.lang.Object, int, java.lang.Object, int, int);
public static native int identityHashCode(java.lang.Object);
public static java.util.Properties getProperties();
public static java.lang.String lineSeparator();
public static void setProperties(java.util.Properties);
public static java.lang.String getProperty(java.lang.String);
public static java.lang.String getProperty(java.lang.String, java.lang.String);
public static java.lang.String setProperty(java.lang.String, java.lang.String);
public static java.lang.String clearProperty(java.lang.String);
public static java.lang.String getenv(java.lang.String);
public static java.util.Map<java.lang.String, java.lang.String> getenv();
public static void exit(int);
public static void gc();
public static void runFinalization();
public static void runFinalizersOnExit(boolean);
public static void load(java.lang.String);
public static void loadLibrary(java.lang.String);
public static native java.lang.String mapLibraryName(java.lang.String);
static {};
}
What is Out in java ?
Out is a constant defined in System class but it is a reference of printStream class. and also Out is a Static field of System class.
What is print/println in java ?
print & println are non-static method defined in printStream Class .
- As both the methods are object methods we call it outside class by the help of object.
Difference between print() and println() in java.
Print() :- It prints all the messages in a single line. There is no new line / break line after printing the message.
Println() :- First it print the messages then it break that line and create a new line. It is used for creating a new line.
What is System.out.println() in java ?
In java System.out.println() is a Statement. Which is used for print the argument passed to it.
Program for System.out.println() :-
public class program
{
public static void main(String args[])
{
System.out.println("I like java.");
}
}
Output :-
Program - 2
class datas
{
public static final int data =100;
}
public class program1
{
public static void main(String args[])
{
System.out.printf("The value of data is : "+datas.data);
}
}
Post a Comment
Post a Comment