Java Basic syntax

Source: Internet
Author: User

Java Basic syntax

A Java program can be thought of as a collection of a series of objects that call each other's methods to work together.

Introduction to classes, objects, methods, instance variables:

Class: A class is a template that describes the behavior and state of a class of objects

Object: Object is an instance of a class that has state and behavior (properties and methods)

Method: The method is the behavior of the class and can have multiple

Instance variables: Each object has its own unique instance variable, and the State (property) of the object is determined by the value of the instance variable

Basic syntax

1, case sensitive, for example: The identifier Hello and Hello is not the same

2. The first letter of the class name should be capitalized, for example: Myfirstjavaclass

3, the method name initials should be lowercase, there are multiple words, then each word should be capitalized, for example: Myfirstmethod

4, save the file, the source file name must match the class name, or the compilation will be error

5. Main method entry, all Java programs are executed by public static void main (String []args) method

Java identifiers

1. All identifiers should start with a letter (A-Z or a-Z), a dollar symbol ($), or an underscore (_).

2. The first character can be a letter (A-Z or a-Z), a dollar symbol ($), an underscore (_), or any character combination of a number

3. The keyword cannot be used as an identifier and is case sensitive

Examples of legal identifiers: Age, $salary, _value, __1_value

Examples of illegal identifiers: 123abc,-salary

Java modifier

1. Access control modifier: default, public, protected, private

2. Non-access control modifier: final, abstract, STRICTFP

Java Basic syntax

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.