现在的位置: 首页 > 综合 > 正文

java —- 初学扎到 hello world!

2013年11月10日 ⁄ 综合 ⁄ 共 681字 ⁄ 字号 评论关闭

通过两种形式 写出一个经典的例子helloworld!

编译工具eclipse + jdk  java  互交式程序(控制台)&& 窗体程序 !

一.

public class helloworld {
	public static void main(String[] arge) {
		System.out.print("hello world!");
	}
}

方法一直接在控制台中输出字符串

二.

public class helloworldclass {
public static void main(String[] arge){
	System.out.println(UserClass.m_messgbox);
}
}
class UserClass{
	static String m_messgbox="hello";
}

方法二通过一个类 中的方法传递 字符串

 

java窗体程序 (java applet)

import java.applet.Applet;
import java.awt.Graphics;

public class WyJavaApplet extends Applet {
	public void paint(Graphics g) {
		g.drawString("hello web Java", 30, 30);
	}
}

 

嵌入Applet的html网页文件内容:

<html>

<head>

<title>嵌入了Applet的网页</title>

</head>

<body>

<applet code="hello.class" width="200" height="40">

</applet>

</body>

</html>

 

java控制台运行效果:

java窗体运行效果

抱歉!评论已关闭.