Java学习 helloworld输出(2)

来源:互联网 发布:mac怎么远程桌面连接 编辑:程序博客网 时间:2024/06/05 00:42

配置好Java所需要的环境,安装eclipse成功完美运行。

开始尝试Java的代码编写运行。

打开Eclipse,建立一个工程


建立一个类


会看到最上面有提示:Type name is discouraged. By convention, Java type names usually start with an uppercase letter

原因是输入的类名“Hello”首字母没有大写,把首字母改为大写的就好了。

public class HelloWorld {    public static void main(String args[]) {    System.out.println("Hello World!");    }}
点击运行即可运行。

一个文件中只能有一个共有的类,并且大小写与文件名一致:

public class HelloWorld

程序的入口:

public static void main(String[] args)

向控制台输出信息:
Syetem.out.println("Hello World!");

在Java中通常所有代码都放在class中,一个class是指一个类,上面的程序中我们编写了一个名字叫做HelloWorld的类,每一个类都要有一个执行方法,入口就是mai(),程序中除了args中是我们自己可以定义的函数,其他的单词都不可以改动。


0 0
原创粉丝点击