1 class HelloWorld{
2     public static void main(String[ ] args) {
3         System.out.print("HelloWorld!!!") ;
4     }
5 }
6   
7   

一.编写类也叫外部结构 

1 class HelloWorld{
2 
3 }       #PS: class是声明类

二.编写main方法,也叫做主方法或程序的入口

1 class helloworld {
2 
3   public static void main (String[ ] args) {
4 
5   }
7 }    
##public static void main (String[] args){
   ...;
} 为程序的入口

 注意:  1.编写在类中  

      2.在一个类中的main方法是可有可无的

         3.如果编写main方法,则在一个类中最多有一个

 

三.编写代码

  一.输出语句

  System.out.print   (编写大小写字母,汉字,数字,以及特殊符号,但是输出后不换行)

  System.out.println  (输出内容同上,但是输出后换行)

 1 class HelloWorld{
 2     public static void main(String[ ] args) {
 3         System.out.println("HelloWorld!!!") ;
 4         System.out.print("hello") ;
 5         System.out.println("HelloWorld") ;
 6         System.out.print("1233123123123123") ;
 7 
 8     }
 9 }
10     输出结果为:
            HelloWorld!!!
            helloHelloWorld
            1233123123123123
View Code

相关文章:

  • 2022-12-23
  • 2021-04-21
  • 2021-07-15
  • 2021-08-15
  • 2021-11-05
  • 2022-12-23
  • 2021-11-14
  • 2021-10-27
猜你喜欢
  • 2021-04-19
  • 2021-06-25
  • 2022-12-23
  • 2021-06-09
  • 2021-09-23
  • 2021-07-30
  • 2021-07-20
相关资源
相似解决方案