Jacva BASICS (II) and jacva Basics

Source: Internet
Author: User
Tags java util

Jacva BASICS (II) and jacva Basics

Data Type Variable Operator

1. Data Type

Basic Type: Class 8

Integer: byte short int long

Floating Point (decimal): double float

Character: char

Boolean: boolean

Reference Type: String type

2. Variables

Essence: a space in the memory used to store various types of data.

Three elements: data type variable name variable value

Syntax for declaring variables:

I: name of the data type variable;

Variable name = variable value;

Ii: data type variable name = variable value;

3. Data Type Conversion

Automatic type conversion:

I: must be compatible with each other.

Ii: If the variable type is small, it can be automatically converted to a type with a large variable type. /* When either of the two numeric types is double

The result is automatically upgraded to the double type. */

4. Scanners

Import package:

Because the scanner class is in the java util package

Import java. util. vendor; // import the util package where the Scanner class is located

Wrote input = new partition (System. in );

System. out. print ("remind yourself of the type of data you want to enter ");

Char num1 = input. next (). charAt (0); // the first character of the char-type syntax input

5. Operators

I. Arithmetic Operators

+-*/%

Ii. Relational operators

><>==! =

Iii. assignment operator

= + =-=/= % =

Iv. logical operators

& Short circuit and | short circuit or & single and | single or! Non

V. Single Object Operator

Num ++ auto plus: num ++ = num + 1 num -- Auto minus: num -- = num-1

++ Executes the operation before the operation, and ++ performs the operation before the operation. -- Likewise

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.