Results 1 to 9 of 9
Thread: importing libraries
- 12-07-2010, 01:49 AM #1
Member
- Join Date
- Dec 2010
- Posts
- 18
- Rep Power
- 0
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.
If it's something already discussed my sincerest apologies but I appreciate the help.Java Code:java import.java.io.*; class ASimpleExample{ public static void main(String []args){ System.out.println("Hello, World!"); }//close main method }//close classLast edited by Eranga; 12-07-2010 at 02:00 AM. Reason: code tags added
- 12-07-2010, 02:00 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Did you read the Java API for that library?
- 12-07-2010, 02:01 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
And also, please use code tags next time, when you are posting code segments. Unformated codes are really hard to read.
- 12-07-2010, 02:16 AM #4
Senior Member
- Join Date
- Mar 2010
- Posts
- 953
- Rep Power
- 4
The line should be
Did you try compiling and running your code again after you removed it?Java Code:import java.io.*;
-Gary-
- 12-07-2010, 02:25 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 12-07-2010, 02:25 AM #6
Senior Member
- Join Date
- Mar 2010
- Posts
- 953
- Rep Power
- 4
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-
- 12-07-2010, 02:31 AM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
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.
- 12-15-2010, 07:57 AM #8
Member
- Join Date
- Dec 2010
- Posts
- 18
- Rep Power
- 0
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.
- 12-16-2010, 05:53 PM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
So you've sorted out the problem yourself. Could you please mark the thread solved then.
Similar Threads
-
Problem in importing jar file in libraries of netbeans
By dataprofiling in forum AWT / SwingReplies: 1Last Post: 03-30-2010, 11:30 AM -
different external libraries for different OS and CVS
By jv_martin in forum EclipseReplies: 1Last Post: 11-04-2009, 02:45 AM -
Not Copying Libraries!?!
By Atriamax in forum NetBeansReplies: 0Last Post: 10-13-2009, 07:56 AM -
How to load new libraries
By Manfizy in forum NetBeansReplies: 2Last Post: 02-11-2009, 06:55 AM -
Reading Libraries.
By leiferouis in forum New To JavaReplies: 4Last Post: 02-07-2009, 08:34 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks