Java Basics. Lesson 5

Слайд 2

Agenda

02

03

04

Arrays Initializers and Anonymous Arrays

“for each” loop

Array Copying

Array Sorting

01

05

Multidimensional Array

06

Ragged Array

Agenda 02 03 04 Arrays Initializers and Anonymous Arrays “for each” loop

Слайд 3

Array copying

02

int[] smallPrimes = {2, 3, 5, 7} ;

new int[] {17, 19,

Array copying 02 int[] smallPrimes = {2, 3, 5, 7} ; new
23}

01

Слайд 4

“for each” loop

for (variable : collection) statement

for(int el : smallPrimes) System.out.println(el);

“for each” loop for (variable : collection) statement for(int el : smallPrimes) System.out.println(el);

Слайд 5

Array Copying

int[] luckyNumbers = smallPrimes ;
luckyNumbers[3] = 12;
int [] copiedValues = Arrays.copyOf(luckyNumbers,

Array Copying int[] luckyNumbers = smallPrimes ; luckyNumbers[3] = 12; int [] copiedValues = Arrays.copyOf(luckyNumbers, luckyNumbers.length);
luckyNumbers.length);

Слайд 6

Array Sorting

Arrays.sort(a);

Array Sorting Arrays.sort(a);

Слайд 7

Multidimensional Array

int [][] matrix = new int[2][3];
int [][] matrixInitialized = {{1,2}, {3,4},

Multidimensional Array int [][] matrix = new int[2][3]; int [][] matrixInitialized = {{1,2}, {3,4}, {5,6}};
{5,6}};

Слайд 8

Ragged Array

Arrays in which different arrays have different length

1
1 1
1 2 1
1

Ragged Array Arrays in which different arrays have different length 1 1
3 3 1
1 4 6 4 1

Слайд 9

Materials

https://www.hackerrank.com/lesson-5

Homework

Chapter 3.10 - 3.10.7 inclusive

Reading

Materials https://www.hackerrank.com/lesson-5 Homework Chapter 3.10 - 3.10.7 inclusive Reading
Имя файла: Java-Basics.-Lesson-5.pptx
Количество просмотров: 50
Количество скачиваний: 0