Similar presentations:
Java Basics. Lesson 5
1.
Java Basics Lesson 5Get started with Java
2.
Agenda01
Arrays Initializers and Anonymous Arrays
02
“for each” loop
03
Array Copying
04
05
06
Array Sorting
Multidimensional Array
Ragged Array
3.
Array copying01
int[] smallPrimes = {2, 3, 5, 7} ;
02
new int[] {17, 19, 23}
4.
“for each” loopfor (variable : collection) statement
for(int el : smallPrimes) System.out.println(el);
5.
Array Copyingint[] luckyNumbers = smallPrimes ;
luckyNumbers[3] = 12;
int [] copiedValues = Arrays.copyOf(luckyNumbers, luckyNumbers.length);
6.
Array SortingArrays.sort(a);
7.
Multidimensional Arrayint [][] matrix = new int[2][3];
int [][] matrixInitialized = {{1,2}, {3,4}, {5,6}};
8.
Ragged ArrayArrays in which different arrays have different length
1
11
121
1331
14641
9.
MaterialsHomework
https://www.hackerrank.com/lesson-5
Reading
Chapter 3.10 - 3.10.7 inclusive