any java person out there??

Bacardi151

Senior member
Dec 15, 2003
540
0
0
i was wondering if the statement "import java.util.*" actually imports all the stuff such as Collection, LinkedList etc. all together or if i have to separately import one by one....i.e. import java.util.AbstractCollection, import java.util.AbstractList, and so forth

thanks in advance!
 

WannaFly

Platinum Member
Jan 14, 2003
2,811
1
0
havent used java in a while but IIRC:

import java.util.* will import ALL classes one banch directly undeneath. so java.util.abstractcollection will import but NOT java.util.abstractcollection.blurb
although, i'm sure its better to only import what you need, unless the compiler/interpreter does that for you.
 

BigJ

Lifer
Nov 18, 2001
21,330
1
81
It imports everything thats in the util package.

EDIT: It imports everything.
 

halik

Lifer
Oct 10, 2000
25,696
1
0
Originally posted by: WannaFly
havent used java in a while but IIRC:

import java.util.* will import ALL classes one banch directly undeneath. so java.util.abstractcollection will import but NOT java.util.abstractcollection.blurb
although, i'm sure its better to only import what you need, unless the compiler/interpreter does that for you.

i dont think thats correct. Import java.util.* should import all the child classes of java.util package.
if you have java.util.color.rgb or something, rgb will get imported if you do java.util.*
 

BigJ

Lifer
Nov 18, 2001
21,330
1
81
Originally posted by: halik
Originally posted by: WannaFly
havent used java in a while but IIRC:

import java.util.* will import ALL classes one banch directly undeneath. so java.util.abstractcollection will import but NOT java.util.abstractcollection.blurb
although, i'm sure its better to only import what you need, unless the compiler/interpreter does that for you.

i dont think thats correct. Import java.util.* should import all the child classes of java.util package.
if you have java.util.color.rgb or something, rgb will get imported if you do java.util.*

I just tested it (haven't used Java in about 4 months) and it imports EVERYTHING under util.

Edit: here's the structure for LinkedList

java.util.AbstractCollection
java.util.AbstractList
java.util.AbstractSequentialList
java.util.LinkedList
 

johnjbruin

Diamond Member
Jul 17, 2001
4,401
1
0
Originally posted by: halik
Originally posted by: WannaFly
havent used java in a while but IIRC:

import java.util.* will import ALL classes one banch directly undeneath. so java.util.abstractcollection will import but NOT java.util.abstractcollection.blurb
although, i'm sure its better to only import what you need, unless the compiler/interpreter does that for you.

i dont think thats correct. Import java.util.* should import all the child classes of java.util package.
if you have java.util.color.rgb or something, rgb will get imported if you do java.util.*

i think you are correct. it should get everything underneath.
 

Bacardi151

Senior member
Dec 15, 2003
540
0
0
is there some sort of update that i need because i seem to have trouble importing some of the utilities, such as Queue, HashMap...should those be inherited when i do the import of java.util.*; ??

and is Edge an actual class?...likewise with Vertex, anybody heard of those two? (this is for a network/graph)
 

BigJ

Lifer
Nov 18, 2001
21,330
1
81
Originally posted by: Bacardi151
is there some sort of update that i need because i seem to have trouble importing some of the utilities, such as Queue, HashMap...should those be inherited when i do the import of java.util.*; ??

and is Edge an actual class?...likewise with Vertex, anybody heard of those two? (this is for a network/graph)


Edge and Vertex are not default classes in Java. Queue is not a class in java. HashMap is a class and its java.util.HashMap;

EDIT: I remember in my AP CS class that they provided us with a Queue interface and we built our own class off of it, ListQueue, etc;

BTW: The JavaDocs are your friend.