public class test{int i;
public int geti()
{
return i;
}
public int getare()
{int a=5*i;
return a;
}
public test(int i)
{
this.i=i;
}
public static void main(String arg[])
{
test test1=new test(4);
} }
把main当成test里面的就行
public int geti()
{
return i;
}
public int getare()
{int a=5*i;
return a;
}
public test(int i)
{
this.i=i;
}
public static void main(String arg[])
{
test test1=new test(4);
} }
把main当成test里面的就行
不是还是要包含嘛?怎么包含呢?用什么语法?是import么?
{
test test1=new test(4);
} }
main(String arg[])必须放在public 类中才能执行。
只有在不同包中的类才用import.
另外我觉得你不能编译的原因可能是上面我说的原因。
同一包中的类之间的调用是不用import的
你的main()函数必需在public的那个类里写
你的这个java文件的名字应该是你的public这个类的名字。