问题:使用javac Calculate.java后是不是应该在目录下有一个mypackage的目录?我的没有..
还有就是编译代码2的时候出现2个错误..我弄了半天弄不出来了,请前辈指教下..
1.代码如下:
package mypackage;
public class Calculate
{
public double volume(double height,double width,double depth)
{
return (height*width*depth);
}
public int add(int x,int y)
{
return(x+y);
}
public int divide(int x,int y)
{
return(x/y);
}
}
2.代码如下:
import mypackage.Calculate;
public class PackageDemo
{
public static void main(String [] args)
{
Calculate calc=new Calculate();
int sum=calc.add(10,20);
double vol=calc.volume(10.3f,13.2f,32.32f);
int div=calc.divide(20,4);
System.out.println("相加得:" + sum);
System.out.println("体积为:" + vol);
System.out.println("相除得:" + div);
}
}