Question : Why command-line arguments?


Question : Why command-line arguments?

c:\>java Adder 10    20
Command line argument

Result is : 30




Explanation of:



[System.out.println();]


System – It is a pre-defined class in java.lang package

out - it is a static variable inside System class of type PrintStream(class reference variable) (i.e.) static PrintStream out;
and PrintStream is a predefined class in java.io package.
Since it is static that’s why we are calling
       System.out
So,  System.out means we are getting the reference to the object of type PrintStream

println()– It is the method in PrintStream class for Standard output stream.
So to access println method , we need PrintStream object which we are getting through System.out.

  So finally its System.out.println---- to produce standard output Stream.



class PrintStream
{
               public void print(String s)
{
               -----------
               -----------
               -----------
}

public void println(String s)
{
               -----------
               -----------
               -----------
}
-------------
-------------
}

                 class System
            {
public static PrintStream out;
-------------
-------------
-------------
}















No comments:

Post a Comment