Java-Foundations-Lesson-3-Arrays
Java-Foundations-Lesson-3-Arrays
Arrays in Java
Your Course
Instructors
George Georgiev
Svetlin Nakov
The Judge System
1. Arrays
2. Array Operations
3. Reading Arrays from the Console
4. For-each Loop
7
Arrays in Java
Working with Arrays of Elements
What are Arrays?
▪ In programming, an array is a sequence of elements
Element’s index
Array of 5
0 1 2 3 4
elements … … … … …
Element of an array
3 4
10 -1
30 20 10 20 5 99 20 -1
20
30 99
5
19
a b c d e
22
int[] numbers = { 1, 2, 3, 4, 5 };
for (int number : numbers) {
System.out.println(number + " ");
}
12345
26
1 2 3 4 5 6 3 2 4 6 8 10 30
3 5 7 9 11 -35 2 2 2 2 2 2 12
27
▪ ▪ Arrays
… hold a sequence of elements
▪ ▪…Elements are numbered
▪ …from 0 to length – 1
▪ Creating (allocating) an array
▪ Accessing array elements by index
▪ Printing array elements
29
Next Steps
▪▪ Join
… the SoftUni "Learn To Code" Community
▪ …
▪ …https://softuni.org
▪ Access the Free Coding Lessons
▪ Get Help from the Mentors
▪ Meet the Other Learners