Basic elements of Java programs

identifier

keyword

notes

import java.applet.*;    //导入java.applet包下的所有类
import java.awt.*;    //导入java.awt包下的所有类
public class JavaApplet extends Applet
{
    /**
    *Applet初始化方法
    *@see java.applet.Applet 类
    *@return 无
    */
    public void init()
    {
        setSize(300,200);    //指定大小
    }
    /**
    *Applet画图操作方法
    *@see java.applet.Applet
    */
    public void paint(Graphics g)
    {
        g.drawString("你好 Java 世界!",100,30);    //绘制图像
    }
}

Modifier

Statements and blocks

public class Hello
{
    public static void main(String[] args)
    {
        System.out.println("你好,Java 世界!");
    }
}

class

method

Main() method

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>