Java Basic Knowledge Collation

Source: Internet
Author: User

1. Data type:

Eight basic data types: integer byte, short, int, long (1, 2, 4, 8 bytes), float float, double (8, 16-bit valid number), cloth boolean character Char

Three large reference data types: objects, interfaces, arrays

2. Automatic type conversion and forced type conversion:

Auto: int a;byte b;a=a+b; here, B is 1 bytes and can only be shifted to a high byte int participating operation

  Note : Byte b;b=b+5; This is an error, because 5 is the int,int+byte can only be calculated by int, after the matter has become an int, so can not be directly assigned to the byte type B

Mandatory: Connect the b= (byte) b+5;

3. Arrays

How to define:

A. Element type [] Array name =new element type [size]

int[] arr = new INT[5];

  Note : The element type can be an object

B. Element type [] Array name =new element type []{element 1, element 2 ...}

int[] arr = new int[]{3,5,1,7};

Int[] arr = {3,5,1,7};

Two-dimensional arrays

int[][] arr = new int[3][2];

int[][] arr = new int[3][];

Int[][] arr = {{1,2,3},{1,2},{1,2,3,5}};

Java Basic Knowledge Collation

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.