Dark Horse Programmer--identifiers, keywords, constants, variables, ternary operators

Source: Internet
Author: User

-------<a href= "http://www.itheima.com" target= "blank" >android training </a> <a href= "/http/ Www.itheima.com "target=" blank ">java training </a>, look forward to communicating with you! ----------

First, identifiers

  1, consisting of letters, numbers, underscores, and the first must be a letter or underline

2. Case-sensitive in C, keyword cannot be used as identifier

Second, the key word 

Definition: A word that is given special meaning by Java.

Features: The expression is English lowercase.

Three, constant

Definition: A fixed value in Java that represents an immutable number.

Categories of Constants in Java:

1, integer constant. All integers.

2, decimal constant. All decimals.

3, Boolean constant. More unique, only two values. True false.

4, character constant. A numeric letter or symbol is identified by a single quotation mark (' ').

5, string constant. Identifies one or more characters in double quotation marks ("").

The 6,null constant. There is only one value: null.

Iv. variables  

Concept: A storage space in memory. Has its own name (variable name) and type (data type).

Function: It is used to keep the same type of data, and can be reused.

Define the format of the variable: data type variable name = initialization value;

automatic promotion of type:

In operations, when low-type data is computed with high-type data, the system automatically promotes the low-type data in the expression to a high type. Such as:

byte B = 3; int C;

C= B + 2; b automatically promotes the operation of the int type.

Five or three-tuple operator

Ternary operators

Format:

(conditional expression)? Expression 1: Expression 2;

A) If the condition is true, the result of the operation is an expression of 1;

b) If the condition is false, the result of the operation is an expression of 2;

Example:

Gets the large number of two numbers.

int x=3,y=4,z;

z = (x>y)? The x:y;//z variable stores a large number of two numbers.

Dark Horse Programmer--identifiers, keywords, constants, variables, ternary operators

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.