zoukankan      html  css  js  c++  java
  • java源文件组成部分

    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

    注意:   1.将代码编写在入口中

          2.可以在入口中编写n条语句,语句就是以" ; "英文分号作为结尾

    PS:

    class HelloWorld{
        public static void main(String[ ] args) {
            System.out.println(1 + 2 + 3) ;  输出结果为6
                    System.out.println("1 + 2 + 3");  输出结果为 1 + 2 + 3
    
        }
    }          
    
      注意:双引号中的内容是原样输出的
    坎坷困难会让你不断的强大起来 -- 前提是你别怂
  • 相关阅读:
    uboot向内核模块传递参数的方法
    arm下用shell控制gpio
    u-boot的内存分布和全局数据结构
    Ambarella SDK build 步骤解析
    MMU段式映射(VA -> PA)过程分析
    ambarella H2 添加文件到ext4文件系统
    使用U-Boot的TFTP(远程/网络内核)
    使用U-Boot的NFS(远程/网络用户空间)
    君正Ingenic X1000E_halley2 更改Logo
    【自动化测试】robotframework中一些建议可能需要掌握的关键字
  • 原文地址:https://www.cnblogs.com/penphy/p/10173300.html
Copyright © 2011-2022 走看看