First knowledge of Java

Source: Internet
Author: User

Javase is mainly used for desktop applications, console development.

1-1 Some of the most common Java words:

public.

Class

Static statically.

void no return type

Main

String strings

Args parameter

of system Systems

Out output device

Print printing

Write the first code:

1  Public class Hello java{2          Public Static void Main (string[] args) {3                 System.out.print ("Hello java");// code 4        }  5 }

Input specification: 1. Each level of the program and the previous level of the program staggered, with the TAB key, empty out of 8 spaces;

2. The curly braces are aligned with this level of code.

Common errors: 1. The class name "Hello Java" must be consistent with the program file name (and the casing needs to be consistent);

2.main method as the entrance of the program, Void is necessary;

3. "String", "System" S must be in the same capitalization, or there will be a program error, Java is case-sensitive;

4. The code line semicolon must have;

5. Quotation marks cannot be omitted.

1-2 notes for Java programs:

 1  public  class       hello java{ 2  public  static  void   main (string[] args) { 3  System.out.print (" Hello Java "); //  single-line comment  4  /*  5   multiline comment  6   multiline comment  7  */ 8  }  9 } 

1. The single-line comment begins with "//" and ends at the end of the line;

2. Multi-line annotations such as the above procedure.

1-3 several common output controls for Java

\ t: outputs 8 spaces, which is equivalent to a tab stop.

\ n: Line break.

11 Public classtest{22 Public Static voidMain (string[] args) {33 System.out.print ("Hello java\n");44 System.out.print ("you \ t good java");55     }66 }77//Output Results88Hello Java99 Hello Java

Note: The output control must be unloaded inside the double quotation mark.

First knowledge of Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.