Topic: java编译的一个问题

  Print this page

1.java编译的一个问题 Copy to clipboard
Posted by: mabinde
Posted on: 2003-02-13 16:50

我写了2个类,类A放在package a里,编译通过,又写了类B,没有放在任何一个包里,我在类B里建立类A的对象,类B的开头已经import a了,但是编译类B的时候还是出现找不到类A的提示,谁知道怎么弄啊
(我在类B里类A对象声明处如:A test;改成a.A test;就没问题了,classpath我都设置了)

2.Re:java编译的一个问题 [Re: mabinde] Copy to clipboard
Posted by: winterld
Posted on: 2003-02-13 17:11

类A有没有public修饰符,如果没有则只能是在 package a中的类的其他类才能引用类A

3.Re:java编译的一个问题 [Re: mabinde] Copy to clipboard
Posted by: menzy
Posted on: 2003-02-13 17:12

the default access field of a class is package, if you want to share it in some other package, you should declare the class to share public.

4.Re:java编译的一个问题 [Re: mabinde] Copy to clipboard
Posted by: mabinde
Posted on: 2003-02-13 17:41

有public啊

5.Re: [Re: mabinde] Copy to clipboard
Posted by: mabinde
Posted on: 2003-02-13 17:43

如果我在类B里类A对象声明处如:A test;改成a.A test;就没问题了

6.Re:java编译的一个问题 [Re: mabinde] Copy to clipboard
Posted by: floater
Posted on: 2003-02-14 02:07

do this:

import a.*;

You need the * in there.

7.Re:java编译的一个问题 [Re: mabinde] Copy to clipboard
Posted by: mabinde
Posted on: 2003-02-14 14:43

是这么写的啊


   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