当前位置: 技术问答>java相关
package怎么使用啊!
来源: 互联网 发布时间:2015-03-02
本文导语: 两个class文件在同一个目录中 //package hello //RandVals.java import java.util.*; public interface RandVals{ int rInt=(int) (Math.random()*22); long rLng=(long)(Math.random()*33); float rFlt=(float)(Math.random()*55); double rDbl=(double)(Math.random(...
两个class文件在同一个目录中
//package hello
//RandVals.java
import java.util.*;
public interface RandVals{
int rInt=(int) (Math.random()*22);
long rLng=(long)(Math.random()*33);
float rFlt=(float)(Math.random()*55);
double rDbl=(double)(Math.random()*66);
}
//package hello
//TestRandVals.java
public class TestRandVals{
public static void main(String[] String){
System.out.println(RandVals.rInt);
System.out.println(RandVals.rLng);
System.out.println(RandVals.rFlt);
System.out.println(RandVals.rDbl);
System.out.println(RandVals.rInt);
System.out.println(RandVals.rLng);
System.out.println(RandVals.rFlt);
System.out.println(RandVals.rDbl);
}
}
如果加上package hello 就出错了,请问一下package到底怎么用,我现在想将这两个
class放在同一个包里面怎样才能成功啊.
//package hello
//RandVals.java
import java.util.*;
public interface RandVals{
int rInt=(int) (Math.random()*22);
long rLng=(long)(Math.random()*33);
float rFlt=(float)(Math.random()*55);
double rDbl=(double)(Math.random()*66);
}
//package hello
//TestRandVals.java
public class TestRandVals{
public static void main(String[] String){
System.out.println(RandVals.rInt);
System.out.println(RandVals.rLng);
System.out.println(RandVals.rFlt);
System.out.println(RandVals.rDbl);
System.out.println(RandVals.rInt);
System.out.println(RandVals.rLng);
System.out.println(RandVals.rFlt);
System.out.println(RandVals.rDbl);
}
}
如果加上package hello 就出错了,请问一下package到底怎么用,我现在想将这两个
class放在同一个包里面怎样才能成功啊.
|
编译时 javac *.java