System.out.println()---in this printing statement why we use (.)i.e dot inbetween ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anu401
    New Member
    • Nov 2009
    • 9

    System.out.println()---in this printing statement why we use (.)i.e dot inbetween ?

    System.out.prin tln()---in this printing statement why we use (.)i.e dot inbetween system.out and out.println?
    please reply
    this question was asked in viva session
  • sukatoa
    Contributor
    • Nov 2007
    • 539

    #2
    System is a class,

    when putting a dot after the System, i means to say if the System class has a static field or method, you may use it through System."static_ field/method"

    The System has a PrintStream called out, it is public so it can be invoked.

    So,

    System.out = PrintStream instance

    By looking to PrintStream class

    there's a public static method named println

    when you call that method(with parameters), it will just simply print the parameter into stream(@console )

    Comment

    • sukatoa
      Contributor
      • Nov 2007
      • 539

      #3
      Similar to that is

      PrintStream ps = new PrintStream(Sys tem.out);
      ps.println("Wel come to the world of ideas");

      Comment

      • anu401
        New Member
        • Nov 2009
        • 9

        #4
        thank you for your answer sir/madam

        Comment

        Working...