编写带有main()的类

public class hm {

    public static void main(String[] args) {

    System.out.println("hanmeng");

    }

}


public:公开给其他类存取

class:类声明

hm:类的名称

static:静态

void:代表没有返回值

main:方法的名称

(String[] args) :必须要传String的数组给此方法当参数,命名为args

System.out.println:打印到标准输出上(默认为命令行)

("hanmeng"):要输出的字符串

;:每一行述句都必须用分号结尾

你可能感兴趣的:(编写带有main()的类)