Constants and Variables in Java

Source: Internet
Author: User

1 identifiers
is a programmer in the definition of Java programs, some of the custom names, such as the class name, method name, function name, variable name and package name.
Naming rules for identifiers:
Consists mainly of English letters, numbers, underscores (_) and dollar ($) characters
Cannot start with a number, cannot be a keyword and a reserved word in Java
Strictly case-sensitive, the middle cannot add spaces
The identifier can be any length
Name to make sense, best to be known

2 Key Words
Access control
Private protected public
Class, method, and variable modifiers
Abstract class extends final implements interface native new
Static strictfp synchronized transient volatile
Program
Break continue return does while if-else for instanceof switch
Case default
Exception handling
Try cathc throw throws
Package related
Import Package
Basic type
Boolean byte char double float int long short null true false
Variable reference
Super this void
Reserved words
Goto CONST
3 variables
Containers used primarily for data storage
Three elements of a variable: variable name variable type variable value
Naming rules:
A naming convention that satisfies identifiers;
Satisfies the hump-type naming specification: one word lowercase (sum) multiple words first word lowercase followed by capital letter (Sumname)
Name as simple as possible, see the name of the idea
4 Naming conventions for class names
Meet Pascal naming specification The first letter of each word must be capitalized listname

5 Data types: Basic data Types (8) and reference data types (classes, interfaces, arrays)
Type bit byte range
Byte81-2^7-2^7-1
Short162-2^15-2^15-1
Int324-2^31-2^31-1
Long648-2^63-2^63-1
Float3241.4e-45-3.4028235e38
Double 6484.9e-324-1.798693134862315e308
Boolean = True&false
Char type is two bytes, 16 bits
6 constant plus final cannot change constants usually used (_) to connect between multiple words in uppercase (_) such as Sum_name

7 ASCII US standard Information interchange codes are primarily used to display modern English and other Western European languages

8 Unicode code char c = ' \u005d ' in front of value plus \u

Constants and Variables in 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.