Java interview real problem analysis is popular all over the network, 6

   double	0.0

   char       \u0000,stay window The system parses spaces

   String	null

   boolean	false

4.10: once the array has allocated space, it can be used

4.11: array direct output, the output is the memory address



5.2D array usage



5.1: syntax of two-dimensional array declaration: data type [] [] array name; (recommended)

				Data type array name[][];

eg://Declare a two-dimensional array

String[][] stuName1;

int stuAges1[][];

5.2: two dimensional array allocation space

5.2.1:Allocate space to a declared two-dimensional array:Fixed length of two-dimensional array,The length of each one-dimensional array is variable.

		Array name=new data type[Length of two-dimensional array][]

		Array name[Two dimensional array index]=new data type[Length of one-dimensional array];



5.2.2:Allocate space to a declared two-dimensional array:The length of each element of a two-dimensional array, that is, a one-dimensional array, is also fixed.

		Array name=new data type[Length of two-dimensional array][Length of one-dimensional array];



5.2.3:Allocate space while declaring a two-dimensional array:

		data type[][] Array name=new data type[Length of two-dimensional array][]

		Array name[Two dimensional array index]=new data type[Length of one-dimensional array];



5.2.4:Allocate space while declaring a two-dimensional array:

	data type[][] Array name=new data type[Length of two-dimensional array][Length of one-dimensional array];

eg://First: allocate space to the array

stuName1=new String[3][4];



//Second: allocate space to the array

stuAges1=new int[3][];

stuAges1[0]=new int[2];

stuAges1[1]=new int[4];

stuAges1[2]=new int[3];



//The third is to declare the array and allocate space at the same time

double[][] height1=new double[3][2];



//The fourth is to declare the array and allocate space at the same time. The length of one-dimensional array is uncertain

double[][] weight1=new double[2][];

weight1[0]=new double[3];

weight1[1]=new double[2];

5.3: 2D array assignment

5.3.1:Dynamic assignment:It can be used in any case.

	  Array name[Two dimensional array index][One dimensional array index]=value;

	  eg://Dynamic assignment to two-dimensional array

stuName1[0][0]="Zhang San 1";

stuName1[0][1]="Zhang San 2";

stuName1[0][2]="Zhang San 3";

stuName1[0][3]="Zhang San 4";



stuName1[1][0]="Li Si 1";

stuName1[1][1]="Li Si 2";

stuName1[1][2]="Li Si 3";

stuName1[1][3]="Li Si 4";



5.3.2:Static assignment:Used when array elements are known

	5.3.2.1:Array will be declared,Allocate space to an array,Static assignment three in one syntax:

data type[][] Array name=new data type[][]{{Value 10,Value 11...},{Value 20,Value 21...}...};



	5.3.2.2:Array will be declared,Allocate space to an array,Static assignment three in one syntax:

			data type[][] Array name={{Value 10,Value 11...},{Value 20,Value 21...}...};

	eg://Static assignment to array

int[][] stuAges2=new int[][] {{20,30},{23,24,25}};



//Static assignment to array

double[][] height2= {{1.75,1.8},{1.7,1.72},{1.6,1.69}};

5.4: two dimensional array traversal

eg:/*Traversing a two-dimensional array with a for loop*/

//The outer loop traverses each space of a two-dimensional array

for (int i = 0; i < stuName1.length; i++) {

	//The inner loop traverses each element of the two-dimensional array, that is, each space of the one-dimensional array

	for (int j = 0; j < stuName1[i].length; j++) {

		System.out.print(stuName1[i][j]+"\t");

	}

	//Output two-dimensional array and wrap one-dimensional array in each space

	System.out.println();

}



System.out.println("*****************************************");

/*Traversing a two-dimensional array with an enhanced for loop*/

//The outer loop traverses each space of a two-dimensional array

for (double[] ds : height2) {

	//The inner loop traverses each element of the two-dimensional array, that is, each space of the one-dimensional array

	for (double d : ds) {

		System.out.print(d+"\t");

	}

	//Output two-dimensional array and wrap one-dimensional array in each space

	System.out.println();

Finally, how to make yourself a technical expert step by step

To tell the truth, if a worker doesn't want to improve himself, there will be no meaning of work. After all, we are not old enough to provide for the aged.

When your skills are getting closer to Ali p7's level step by step, there is no doubt that your salary will rise. At the same time, you can learn more and deeper skills and become more powerful.

Recommend a necessary learning note on the road to Java architecture, which is quite comprehensive!!!

The adult world is not easy to two words. Before a time, tiktok saw a programmer who was working overtime for two weeks to 2 midnight. If you want to get a high salary in this industry, you have no choice but to improve your hard power.

You know what? Now some fresh students' internship salary has surpassed that of programmers who have been developing for 5 years. The internship salary is 26K and 30K. Don't you have a sense of urgency? It's really embarrassing to be a fresh student after so many years!

If you enter this industry, don't use the lack of time to learn as an excuse. This industry is to keep learning, otherwise you can only be laid off. Therefore, seize the time to invest in yourself, learn more technology, face difficulties and relax in the future!

To get these carefully sorted out materials, please remember

Video of working overtime for two weeks to 2 a.m. If you want to get a high salary in this industry, you have no choice but to improve your hard power.

You know what? Now some fresh students' internship salary has surpassed that of programmers who have been developing for 5 years. The internship salary is 26K and 30K. Don't you have a sense of urgency? It's really embarrassing to be a fresh student after so many years!

If you enter this industry, don't use the lack of time to learn as an excuse. This industry is to keep learning, otherwise you can only be laid off. Therefore, seize the time to invest in yourself, learn more technology, face difficulties and relax in the future!

To get these carefully sorted out materials, please remember

————[follow] + [forward] + [like] support me! It's not easy to create! Click here to go to my Tencent document for free download

Keywords: Java Back-end Interview Programmer

Added by astaroth on Mon, 27 Dec 2021 16:43:10 +0200