• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

System.out.println();

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
whats is the internal coding of System.out.println();how is it works....i saw a coding in System class

class System
{
public static final PrintStream out=null;
}


but i did'nt undestand...this is has-A relationship but where the object of PrintStream class is creating.
please help me......thanks
 
Marshal
Posts: 76862
366
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You shouldn’t care what the internal coding is, but if you insist:-
  • 1: Find the src.zip file in your Java installation folder.
  • 2: Unzip it.
  • 3: Navigate to the ja‍va folder
  • 4: Navigate to the lang folder
  • 5: Read the System.java file
  • If you need the JVM code, you can download it too, but I can’t remember whence.
     
    Ranch Hand
    Posts: 47
    Eclipse IDE Spring Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hello,

    System.out.println()

    out => PrintStream

    PrintStream => pirntln method invoke print method => Javadoc PrintStream println(java.lang.String)

    docs.oracle.com wrote: public void print(String s)
    Print a string. If the argument is null then the string "null" is printed. Otherwise, the string's characters are converted into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the write(int) method.
    Parameters:
    s - The String to be printed



    Javadoc PrintStream print(java.lang.String)

    If you want an implementation, you can extract the code in open-jdk :

    open-jdk source
     
    Ranch Hand
    Posts: 179
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Ritesh raushan wrote:but i did'nt undestand...this is has-A relationship but where the object of PrintStream class is creating.



    What is there, you did not understand? It simply says that the System class has an object "out" of PrintStream class. You have already shown the code there. If you are worried about the initialization of "out",then

    shows you how "out" is reassigned

    Cheers
     
    my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
    the value of filler advertising in 2021
    https://coderanch.com/t/730886/filler-advertising
    reply
      Bookmark Topic Watch Topic
    • New Topic