怎样创建一个子包和一个基础包!在线等,高分 创建一个名为calculator的子包,其基础包名为parent.子包中应包含一个location类,location类包含一个名为disp()的方法;用于显示"child子包中location类"的消息.创建一个名为parenttest的类,使它导入此子包,并调用location类的disp方法. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 创建一个名为calculator的子包,其基础包名为parent.这句话没看懂。 在代码全部的创建一个名为calculator的子包,其基础包名为parent子包与父包的关系\. 我是这样理解的:parent.calculator.Location#disp()disp() { System.out.println("child子包中location类");}parent.calculator.Parenttest#doSomething()doSomething() { 调用Location的disp方法} import child.location;public class parenttest{ public static void main(Strint [] args){ location loct=new location(); loct.disp(); }package child;pubic class location{ location(){}; void disp(){ System.out.println("这是子包的详细信息"); }}请各位帮助在改下,谢谢 ////////////////////////////////////////////////////////// parent.ParentTest.java///////////////////////////////////////////////////////package parentimport calculator.location;public class ParentTest{ public static void main(Strint [] args) { Location loct=new Location(); loct.disp(); }}///////////////////////////////////////////////////////// parent.calculator.Location.java///////////////////////////////////////////////////////package calculator;pubic class Location{ Location(){}; public void disp() { System.out.println("child子包中location类"); }} 创建一个名为child的子包,其基础包名为parent.子包中应包含一个location类,location类包含一个名为disp()的方法;用于显示"child子包中location类"的消息.创建一个名为parenttest的类,使它导入此子包,并调用location类的disp方法. wyjkk 差不多全对,而且把lz的不规范的写法改了,可惜...1.import calculator.location;=>calculator.Location;2.自己也写了parent.calculator.Location.java为什么package不是package parent.calculator;?3.sub包为child?那再改改package parent.child;////////////////////////////////////////////////////////// parent.ParentTest.java///////////////////////////////////////////////////////package parent;import calculator.Location;public class ParentTest{ public static void main(Strint [] args) { Location loct=new Location(); loct.disp(); }}///////////////////////////////////////////////////////// parent.child.Location.java///////////////////////////////////////////////////////package parent.child;pubic class Location{ Location(){}; public void disp() { System.out.println("child子包中location类"); // 还有一个问题,你想要什么样的信息?反射自己看吧 }} ////////////////////////////////////////////////////////// parent.ParentTest.java///////////////////////////////////////////////////////package parent;import parent.child;// 这段忘了改了,你再试试,不懂叫我public class ParentTest{ public static void main(Strint [] args) { Location loct=new Location(); loct.disp(); }}///////////////////////////////////////////////////////// parent.child.Location.java///////////////////////////////////////////////////////package parent.child;pubic class Location{ Location(){}; public void disp() { System.out.println("child子包中location类"); // 还有一个问题,你想要什么样的信息?反射自己看吧 }} 如何创建包俺也不是很懂 俺的理解就是:所谓的pakage就是文件夹新建个parent文件夹在parent文件夹里再建个calculator文件夹这样所谓的基础包 子包就都有了再来添加类==============================================================子包中应包含一个location类,location类包含一个名为disp()的方法;用于显示"child子包中location类"的消息.这个直接写代码就可以了package parent.calculatorpublic class Location{ disp(){ System.out.println("child子包中location类"); }}==============================================================创建一个名为parenttest的类,使它导入此子包,并调用location类的disp方法. import parent.calculator;public class Parenttest{ public static void main(string[] args){ Location child=new Location; child.disp; }} import parent.calulator.* ??? 我不知道理解对不对,我是这么写的,你自己是不是这样 ////////////////////////////////////////////////////////// parent.ParentTest.java///////////////////////////////////////////////////////package parent;import parent.calculator.Location;public class ParentTest{ public static void main(Strint [] args) { Location loct=new Location(); loct.disp(); }}///////////////////////////////////////////////////////// parent.calculator.Location.java///////////////////////////////////////////////////////package parent.calculator;pubic class Location{ Location(){}; public void disp() { System.out.println("child子包中location类"); }} java 里的基础包一般是指最常用的包…… 不知道楼主这里的基础包是想说啥还是一个面试题?楼主,这家公司你不用去了…… child在parent文件夹下而parent文件夹下有child文件夹child文件夹下有Location.java这个文件,因为是在访问在不同包的类的方法,方法前要加上修饰符publicParentTest.java在parent下面package parent;import parent.child.Location;public class ParentTest{ public static void main(String [] args) { Location loct=new Location(); loct.disp(); }}package parent.child;public class Location{ public Location(){}; public void disp() { System.out.println("child子包中location类"); }} Class<T>泛型问题 在线等待,SWING问题 一个简单的数组查询,为什么不好用 关于在JLabel上放的图片在鼠标拖动时候不仅仅一闪一闪的,而且有时候图片会消失(有代码)50分~ 长见识了 面对JAVA的心态 求java jdk1.4版的下载地址(最好是国内的) 请教一个关于java线程的问题 请教JAVA高手一个JBUILDER中关于GUI设计的一个问题::有分赠送 applet中使用了jbuilder4的class,怎样才能在ie中显示出来 JTextArea加滚动条有问题?? 怎么在JList里加内容!
子包与父包的关系\.
disp() {
System.out.println("child子包中location类");
}parent.calculator.Parenttest#doSomething()
doSomething() {
调用Location的disp方法
}
public static void main(Strint [] args){
location loct=new location();
loct.disp();
}package child;pubic class location{
location(){};
void disp(){
System.out.println("这是子包的详细信息");
}
}请各位帮助在改下,谢谢
////////////////////////////////////////////////////////
// parent.ParentTest.java
///////////////////////////////////////////////////////
package parentimport calculator.location;public class ParentTest
{
public static void main(Strint [] args)
{
Location loct=new Location();
loct.disp();
}
}
///////////////////////////////////////////////////////
// parent.calculator.Location.java
///////////////////////////////////////////////////////package calculator;pubic class Location
{
Location(){};
public void disp()
{
System.out.println("child子包中location类");
}
}
1.import calculator.location;
=>calculator.Location;
2.自己也写了parent.calculator.Location.java
为什么package不是
package parent.calculator;?
3.sub包为child?
那再改改
package parent.child;////////////////////////////////////////////////////////
// parent.ParentTest.java
///////////////////////////////////////////////////////
package parent;import calculator.Location;public class ParentTest
{
public static void main(Strint [] args)
{
Location loct=new Location();
loct.disp();
}
}
///////////////////////////////////////////////////////
// parent.child.Location.java
///////////////////////////////////////////////////////package parent.child;pubic class Location
{
Location(){};
public void disp()
{
System.out.println("child子包中location类");
// 还有一个问题,你想要什么样的信息?反射自己看吧
}
}
// parent.ParentTest.java
///////////////////////////////////////////////////////
package parent;import parent.child;// 这段忘了改了,你再试试,不懂叫我public class ParentTest
{
public static void main(Strint [] args)
{
Location loct=new Location();
loct.disp();
}
}
///////////////////////////////////////////////////////
// parent.child.Location.java
///////////////////////////////////////////////////////package parent.child;pubic class Location
{
Location(){};
public void disp()
{
System.out.println("child子包中location类");
// 还有一个问题,你想要什么样的信息?反射自己看吧
}
}
所谓的pakage就是文件夹
新建个parent文件夹
在parent文件夹里再建个calculator文件夹
这样所谓的基础包 子包就都有了再来添加类
==============================================================
子包中应包含一个location类,location类包含一个名为disp()的方法;用于显示"child子包中location类"的消息.
这个直接写代码就可以了
package parent.calculatorpublic class Location{
disp(){
System.out.println("child子包中location类");
}
}
==============================================================
创建一个名为parenttest的类,使它导入此子包,并调用location类的disp方法.
import parent.calculator;public class Parenttest{
public static void main(string[] args){
Location child=new Location;
child.disp;
}
}
////////////////////////////////////////////////////////
// parent.ParentTest.java
///////////////////////////////////////////////////////
package parent;import parent.calculator.Location;public class ParentTest
{
public static void main(Strint [] args)
{
Location loct=new Location();
loct.disp();
}
}///////////////////////////////////////////////////////
// parent.calculator.Location.java
///////////////////////////////////////////////////////package parent.calculator;pubic class Location
{
Location(){};
public void disp()
{
System.out.println("child子包中location类");
}
}
不知道楼主这里的基础包是想说啥还是一个面试题?楼主,这家公司你不用去了……
而parent文件夹下有child文件夹
child文件夹下有Location.java这个文件,因为是在访问在不同包的类的方法,方法前要加上修饰符public
ParentTest.java在parent下面
package parent;import parent.child.Location;public class ParentTest
{
public static void main(String [] args)
{
Location loct=new Location();
loct.disp();
}
}
package parent.child;public class Location
{
public Location(){};
public void disp()
{
System.out.println("child子包中location类");
}
}