中易网

java不同包之间类的调用的问题

答案:4  悬赏:50  
解决时间 2021-01-11 10:57
  • 提问者网友:不爱我么
  • 2021-01-10 21:22
java不同包之间类的调用的问题
最佳答案
  • 二级知识专家网友:上分大魔王
  • 2021-01-10 22:50
package com.windows;
import com.win.*;
class mytest
{
public void ha()
{
test t= new test();
t.haha();
}
public void ho()
{

test1 t1= new test1();
t1.hoho();
}
public static void main(String[]args)
{
myTest my = new myTest();
my.ho();
my.ha();
还有一种就是直接给你ho();ha();设置成静态的(static)的;
this.ho();
thsi.ha();
}
}
全部回答
  • 1楼网友:雾月
  • 2021-01-11 02:19
import com.win.*;
你写上边这句了,只要实例化一下,就可以调test和test1里面的类
  • 2楼网友:行雁书
  • 2021-01-11 01:36
直接在mytest类的main方法中调用:test t = new test ();test1 t1 = new test1 ();
其中t可以调用test类中的方法,t1可以调用test1中的方法。
  • 3楼网友:持酒劝斜阳
  • 2021-01-11 00:08
import com.win.*;
class mytest
{
public void ha()
{
}
public void ho()
{
}
public static void main(String[]args)
{
test t=new test();
t.haha();
text1 t1=new text1();
t1.hoho();
}
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息