JAVA program, basic data type, data type conversion, variables and constants, common operators, java Operators

Source: Internet
Author: User

JAVA program, basic data type, data type conversion, variables and constants, common operators, java Operators

I. Basic Data Types

Integer type: byte, short, int (commonly used), long (usually used)

Defines a variable int a = 10;

 

Floating point type (decimal): float, double (commonly used)

 

Character Type: char (not a string)

Char B = 'A'

Escape Character class: Common \ backslash character \ t vertical tab \ r carriage return \ n line feed

 

Boolean (logical type): true, false

 

Ii. type conversion

Forced conversion and automatic conversion

Int m = 1;

Long n = 4;

N = m; short values can be automatically assigned to long values.

M = n requires us to forcibly convert the Syntax: m = (int) n

The forced conversion between values is implemented ().

 

3. Variables and constants

Variable: int a, B; double c = 3.14;

Constant final: values can only be assigned once. All objects share values. final double d = 3.1415;

 

Iv. Common Operators

Arithmetic Operators: +,-, *,/, %, ++, and ,--

Relational operators: >>=<==! =

Logical OPERATOR: & |!

Other operators: + =-= * =/= % =? : =

 

 

    

    

 

 

 

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.