The Artima Developer Community
Sponsored Link

Java Answers Forum
"import" question

3 replies on 1 page. Most recent reply: Mar 20, 2002 2:41 PM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Lynn Hollerman

Posts: 67
Nickname: gmholler
Registered: Mar, 2002

"import" question Posted: Mar 19, 2002 6:58 AM
Reply to this message Reply
Advertisement
Being new to Java, I have read lots of sample programs, and have noticed something when using the "import" statement - a lot of the programs have lines like:

import java.awt.*
import java.awt.event.*

What is the purpose of that 2nd import? Doesn't the first line mean "all possibilities beginning with 'java.awt.'"? If that's true, then wouldn't "java.awt.event.*" be a part of the first import? I must be misunderstanding the meaning of '*' in Java, as none of the books or tutorials I've read answer this!

Thanks in advance!

Lynn.


Shivakumar

Posts: 1
Nickname: doctor
Registered: Mar, 2002

Re: "import" question Posted: Mar 19, 2002 7:17 AM
Reply to this message Reply
Hi Lynn..

Actually.. the import java.awt.*; is meant to import the classes present in the package java.awt but not the packages present in java.awt ..
java.awt.event is an another package .. the name of it is so.. bcoz this package contains the classes which supports eventhandling on awt components.. thats all..

but that doesn't mean that import java.awt.*; means importing java.awt.event.* also..

any doubts..
do reply
regards
DOCTOR

Lynn Hollerman

Posts: 67
Nickname: gmholler
Registered: Mar, 2002

Re: "import" question Posted: Mar 19, 2002 7:21 AM
Reply to this message Reply
Thanks for the quick reply!!

I see what you're saying...but there's one thing I still don't understand...how do you know that they're 2 different packages? Experience?

Thanks again!

Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: "import" question Posted: Mar 20, 2002 2:41 PM
Reply to this message Reply
Go to the following link and click Tree

http://java.sun.com/j2se/1.4/docs/api/index.html

and you will see the tree architecture of the api.

import java.awt.*;
referes to a different tree of classes
then java.awt.event.

Flat View: This topic has 3 replies on 1 page
Topic: question on awt Previous Topic   Next Topic Topic: swings

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use