第一个java程序

 

1、

[root@centos7 test5]# ls
first.java 
[root@centos7 test5]# cat first.java         ## 源文件
public class first{                         ##类名为first

        public static void main(String[] args){      ## 方法为main
        System.out.println("liujiaxin01");
        System.out.println("xxxxxxxxxxx");
        System.out.println("yyyyyyyyyyy");
        }
}
[root@centos7 test5]# javac first.java       ## 编译为.class文件
[root@centos7 test5]# ls
first.class  first.java
[root@centos7 test5]# java first        ## 运行
liujiaxin01
xxxxxxxxxxx
yyyyyyyyyyy

 

posted @ 2022-04-13 17:03  小鲨鱼2018  阅读(18)  评论(0编辑  收藏  举报