Results 1 to 9 of 9
  1. #1
    carman12 is offline Member
    Join Date
    Dec 2010
    Posts
    18
    Rep Power
    0

    Default importing libraries

    Hi, i'm new to the forum and i've been searching but can't seem to get the info i need.

    I'm doing a bit of coursework and one of the questions state if I remove java import.io from the code below what would happen.
    You should know i removed it and nothing happen. Can anyone explain why.

    Java Code:
    java import.java.io.*;
    
    class ASimpleExample{
         public static void main(String []args){
              System.out.println("Hello, World!");
         }//close main method
    }//close class
    If it's something already discussed my sincerest apologies but I appreciate the help.
    Last edited by Eranga; 12-07-2010 at 02:00 AM. Reason: code tags added

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    And also, please use code tags next time, when you are posting code segments. Unformated codes are really hard to read.

  4. #4
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    The line should be
    Java Code:
    import java.io.*;
    Did you try compiling and running your code again after you removed it?

    -Gary-

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  6. #6
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    Sorry, that was a mean trick question, and your instructor already pulled one trick question on you. Yes, the program compiles and runs just fine without that import. The reason is simply that the program does not use any code from the java.io libraries.

    -Gary-

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    More importantly, OP is worried that as you said he believe there is a trick, and should end with an error. Since nothing is going wrong he's worried.

  8. #8
    carman12 is offline Member
    Join Date
    Dec 2010
    Posts
    18
    Rep Power
    0

    Default thanks for the help

    I appreciate the help, turns out all the trick to the question was that the code had my importing io but there was nothing but input into the code. all the code was doing, print hello world.

    thanks again for the help i realy appreciate.

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

Similar Threads

  1. Problem in importing jar file in libraries of netbeans
    By dataprofiling in forum AWT / Swing
    Replies: 1
    Last Post: 03-30-2010, 11:30 AM
  2. Replies: 1
    Last Post: 11-04-2009, 02:45 AM
  3. Not Copying Libraries!?!
    By Atriamax in forum NetBeans
    Replies: 0
    Last Post: 10-13-2009, 07:56 AM
  4. How to load new libraries
    By Manfizy in forum NetBeans
    Replies: 2
    Last Post: 02-11-2009, 06:55 AM
  5. Reading Libraries.
    By leiferouis in forum New To Java
    Replies: 4
    Last Post: 02-07-2009, 08:34 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
  •