Java foundation 4 - Other data types and operators

xiaoxiao2021-04-08  284

1. The Java in the middle group is an object. Declaration method: int sample [] = new int [10]; // Syntax 1 int [] Sample = new int [10]; // Syntax 2 int [] Sample = {0, 1, 2, 3, 4, 5 , 6, 7, 8, 9}; // If the initialization array of {} can generate an exception arrayindexoutofboundsexception if the runtime is overflow.

2, multi-dimensional array int reference [] [] = new int [10] [20];

Can define irregular array int reference [] [] = new int [3] []; table [0] = new int [4]; table [1] = new int [2]; table [2] = new int = 2];

3, array reference assignment, just simple to modify the number of variables.

4, for-each form Access arrays to iterate all content of a collection. INT NUMS [] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int sum = 0; for (int x: NUMS) SUM = X;

For-Each form can be nested,

5, string String object, is not changeable, once created, the character sequence cannot be changed. Use == Compare whether the references of the two strings point to the same object, Equals compares whether the two string sequences are the same. The StringBuffer class provides the changeable string function to improve efficiency.

6, the bit operator can not be used for Boolean, Float, Double or class type & | ^ >> right shift >>> No symbol right shift << left shift ~

转载请注明原文地址:https://www.9cbs.com/read-132828.html

New Post(0)