Topic: 关于import

  Print this page

1.关于import Copy to clipboard
Posted by: zangtt
Posted on: 2005-09-09 10:45

请问:可以直接import相同目录下的类吗?

PrimNumber.class和TestPack.java存放于同一目录,在TestPack.java中直接导入PrimNUmber这个类,即
import PrimNumber;
编译不能通过。

2.Re:关于import [Re: zangtt] Copy to clipboard
Posted by: why
Posted on: 2005-09-09 11:01

use package, please.

3.Re:关于import [Re: zangtt] Copy to clipboard
Posted by: zangtt
Posted on: 2005-09-09 11:07

可是,我在书上看到的说:可以使用import语句引入无名包,但要保证两个类在同一目录中。

4.Re:关于import [Re: zangtt] Copy to clipboard
Posted by: why
Posted on: 2005-09-09 11:24

You must be reading something old.
Prior to J2SE 1.4, it is allowed to import classes from the default package.

BTW, zcjl wrote a topic 如何引用没有包结构的类
http://www.cjsdn.net/post/view?bid=1&id=155189
which might be interesting to certain people, but of course, that's BAD practice.Smile

5.Re:关于import [Re: zangtt] Copy to clipboard
Posted by: zangtt
Posted on: 2005-09-09 11:40

十分感谢Smile

6.Re:关于import [Re: zangtt] Copy to clipboard
Posted by: zcjl
Posted on: 2005-09-09 12:24

对于同一package下的类,是无需import的

7.Re:关于import [Re: zangtt] Copy to clipboard
Posted by: 大眼睛的女孩
Posted on: 2005-09-09 20:17

不是很清楚~~

8.Re:关于import [Re: 大眼睛的女孩] Copy to clipboard
Posted by: why
Posted on: 2005-09-09 20:53

大眼睛的女孩 wrote:
不是很清楚~~

有啥不是很清楚?
提問要負責任一點!

9.Re:关于import [Re: zangtt] Copy to clipboard
Posted by: awardwy
Posted on: 2005-09-10 10:28

scream for use package!!!!!!!


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923