【java hello world程序代码】相信很多人都知道,无论是任何一本java教科书,最开始的基础都是java hello world,所以今天我们把java hello world 世界你好!写一个小的程序代码给大家,愿对初学者有一定的指导。

public class HelloWorld{
public static void main(String args[]){
System.out.print("Java HelloWorld!");
}
}解释:以上java小应用程序代码输出结果为Java HelloWorld!。
HelloWorld.java
import java.util.*;
public class HelloWorld {
public static void main(String[] args){
System.out.println(new Date());
Properties p = System.getProperties();
p.list(System.out);
try{
Thread.currentThread().sleep(5 * 1000);
}catch(InterruptedException e){}
}
}public class Parcel{
class Contents{
private int i = 11;
public int value(){return i;}
}
class Destination{
private String label;
Destination(String what){label = what;}
String readLabel(){return label;}
}
public static void main(String[] args)
{
Parcel p = new Parcel();
Parcel.Contents c = p.new Contents();
Parcel.Destination d = p.new Destination("Tanzania");
}
}
// 从内部类集成
class Outer{
class Inner{}
}
public class InheritInner extends Outer.Inner{
//InheritInner() {} //Won't compile,need outer class'instance handle
InheritInner(Outer outer){
outer.super();
}
public static void main(String[] args){
Outer outer = new Outer();
InheritInner ii = new InheritInner(outer);
}
}用以下命令来调试代码: javac HelloWorld.java java HelloWorld
HelloWorld.java
package mars;
public class HelloWorld {...}
javac -d . HelloWorld.java //加上-d .参数后,javac会自动创建mars文件夹,并将HelloWorld.class放入该文件夹内
mars.mf (注意最后面一行内容后面必须有一个空行,否则最后一行将被丢弃。)
Main-Class: mars.HelloWorld
jar cvfm mars.jar mars.mf mars
java -jar mars.jar
// 内部类:生成Parcel.class、Parcel$Destination.class、Parcel$Contents.class
// 如果内部类是匿名的,那么编译器会简单地生成数字,把它们作为内部类标识符使用。若内部类嵌套于其他内部类中,则它们的名字简单地追加在一个$以及外部类标识符的后面。
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
