Results 1 to 4 of 4
  1. #1
    JavaJunkie is offline Member
    Join Date
    Apr 2009
    Posts
    12
    Rep Power
    0

    Default Java basic question

    Hi,

    I really don't understand, why the statement System.out.println() is correct. First, the out variable returns PrintStream object, which has println method, and this is in java.io package. So, how complier finds it? This is making me bemuse .

    Thanks in advance for any valuable suggestion.


    JJ

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    out doesn't "return" a PrintStream object, it is a PrintStream object.

  3. #3
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    java.io.PrintStream is used only in the class java.lang.System, which has already been complied. You only need imports when you explicitly use a class name.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  4. #4
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    6

    Default

    You can actually import java.lang.System.*; and then just type out.println()

    (pointless fact but a little neat I guess)
    Liberty has never come from the government.
    Liberty has always come from the subjects of government.
    The history of liberty is the history of resistance.
    The history of liberty is a history of the limitation of governmental power, not the increase of it.

Similar Threads

  1. Basic question on OOP.
    By madthinker in forum New To Java
    Replies: 7
    Last Post: 01-26-2009, 07:09 PM
  2. Basic MouseListener Question
    By jshailes in forum AWT / Swing
    Replies: 9
    Last Post: 01-15-2009, 08:58 AM
  3. Basic array question
    By jigglywiggly in forum New To Java
    Replies: 12
    Last Post: 01-09-2009, 04:44 PM
  4. Basic question about EJB
    By javaplus in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 07-15-2008, 05:44 PM
  5. Very basic question
    By gvi in forum New To Java
    Replies: 2
    Last Post: 10-30-2007, 06:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •