Android Development Primer (2) Java Basics

Source: Internet
Author: User

Java variables

A declared variable outside a class that cannot have a variable must first be declared, then assigned, before it can be used

Basic Data Type logic: Boolean (True,false) literal: char integer: Btye,short,int,long floating-point type: float,double

Reference data types: classes, interfaces, arrays

Java each integer type has a fixed table data range and field length, not affected by the specific operating system mosquito nets Call the Java language's shaping constants default to int, declaring a long constant must be added "L" AK "L" as long a=555555l;

The Java floating-point constant defaults to double, and if you want to declare a constant of type float, you must add F or F as float a=12.3f after the number;

The basic data type conversion 1.boolean type cannot be converted to another data type 2. Shaping, character-shaped, floating-point conversion capacity small automatic conversion to large capacity capacity of large size to add a forced conversion character, but it may cause precision reduction or overflow byte,short, Char does not convert to each other, in the calculation between the three, the first will automatically go to the int type, then do the operation, return to the int type, pay special attention to

Java operators

The meaning of + + (-)

+ + (-) in the previous, said to self-add or subtract, and then take the value of other things + + (-) in the after, said to take the value to do other things, done before the original value of self-added or self-reduction

int a=20;b=10;

a=b++;//after running a=10,b=11

int a=20;b=10; a=++b;//after running a=11,b=11

"+" In addition to the addition operator, or string connector, when the "+" on either side of the string, will automatically turn the other side into a string, and then a string connection

Android Development Primer (2) Java Basics

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.