当前位置: 技术问答>java相关
关于IMPORT和PACKAGE
来源: 互联网 发布时间:2015-03-04
本文导语: 目录:------------- e:javaHelloWorldmyPackages 2个CLASS文件:-------------- e:javaHelloWorldHelloWorld.class e:javaHelloWorldmyPackagespackage1.class (其中HelloWorld.class中引用package1.class) set classpath----------------------- SET CLASSPATH=.;d:jb5jdk13lib;d:jb5jd...
目录:-------------
e:javaHelloWorldmyPackages
2个CLASS文件:--------------
e:javaHelloWorldHelloWorld.class
e:javaHelloWorldmyPackagespackage1.class
(其中HelloWorld.class中引用package1.class)
set classpath-----------------------
SET CLASSPATH=.;d:jb5jdk13lib;d:jb5jdk13libtools.jar;d:jb5jdk13libdt.jar;E:java
请教
2个文件中的PACKAGE和IMPORT如何写?
e:javaHelloWorldmyPackages
2个CLASS文件:--------------
e:javaHelloWorldHelloWorld.class
e:javaHelloWorldmyPackagespackage1.class
(其中HelloWorld.class中引用package1.class)
set classpath-----------------------
SET CLASSPATH=.;d:jb5jdk13lib;d:jb5jdk13libtools.jar;d:jb5jdk13libdt.jar;E:java
请教
2个文件中的PACKAGE和IMPORT如何写?
|
麻烦你试一下:
//HelloWorld.java----------
import myPackages.package1;
public class HelloWorld
{
public static void main(String[] args)
{
package1 pk=new package1("dfadfasd");
}
public static void main1(String[] args)
{
System.out.println("Hello world!!");
}
}
//package1.java-----------
package myPackages;
public class package1
{
public package1(String outPut)
{
System.out.println(outPut);
}
}
//HelloWorld.java----------
import myPackages.package1;
public class HelloWorld
{
public static void main(String[] args)
{
package1 pk=new package1("dfadfasd");
}
public static void main1(String[] args)
{
System.out.println("Hello world!!");
}
}
//package1.java-----------
package myPackages;
public class package1
{
public package1(String outPut)
{
System.out.println(outPut);
}
}