Java Basic Syntax

Source: Internet
Author: User
Tags modifiers java keywords

Before starting the Java basic syntax, explain the basic specifications of the Java program:
    • Case sensitive, such as person and person are different
    • The first letter of the class name is capitalized, and if the class name consists of multiple words, the first letter of each word is capitalized, for example HelloWorld
    • Method names should follow the hump naming method, beginning with a lowercase letter, if it contains multiple single, followed by a single capitalization, such as Findminnumber
    • The source file name must be the same as the class name
    • Java program starts execution by public static void main (string [] args) method
Java identifiers, such as class name, variable name, method name
    • All representations are (A-Z) or (A-Z) or ($) or (_) Start
    • The first character is followed by a (A-Z) or (A-Z) or ($) or (_) or (any number) combination
    • Keyword cannot be used as an identifier
    • Identifier Case sensitive
    • Examples of legal identifiers: Age, $salary, _value
    • Examples of illegal identifiers: 2twice,-salary
Java modifiers, modifying methods and properties in a class
    • Access control modifier: default,public,protected,private
    • Non-access control modifier: FINAL,ABSTRACT,STRICTFP
Java variables
    • class variables
    • Member variables
    • Local variables
Java arrays

An array of objects on the heap that can hold multiple variables of the same type, named Specification byte[] Buffer

Java Enumeration

Enumerations can only be pre-set values.

class HelloWorld {    public static void main(String[] args) {        FreshJuice juice = new FreshJuice();        juice.size = FreshJuice.FreshJuiceSize.MEDIUM;    }}class FreshJuice {    enum FreshJuiceSize { SMALL, MEDIUM, LARGE }    FreshJuiceSize size;}
Java keywords, keywords are lowercase access control
    • Private
    • Protected
    • Public
Class, method, and variable modifiers
    • Abstract
    • Class
    • Extends
    • Final
    • Implements
    • Interface
    • Native
    • New
    • Static
    • Strictfp
    • Synchronized
    • Transient
    • Volatile
Program Control statements
    • Break
    • Continue
    • Do
    • While
    • For
    • If
    • Else
    • instanceof
    • Return
    • Switch
    • Default
    • Case
Error handling
    • Assert
    • Catch
    • Finally
    • Throw
    • Throws
    • Try
Package related
    • Import
    • Package
Basic type
    • Boolean
    • Byte
    • Char
    • Double
    • Float
    • Int
    • Long
    • Short
    • Null

Variable reference

    • Super
    • This
    • void

Reserved keywords

    • Goto
    • Const

Java Basic Syntax

Related Article

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.