✅ Day 2: Arrays – Traversals, Operations & Basic Problems 🎯 Goals of the Day Understand 1D array declaration and initialization in Java Learn array traversal techniques Solve beginner-level problems on arrays 📘 1. Arrays in Java – The Basics An array is a collection of elements of the same type stored in contiguous memory. 🔹 Declaration: int [] arr = new int [ 5 ]; // creates an array of size 5 int [] nums = { 1 , 2 , 3 , 4 , 5 }; // directly initialized 🔹 Access: System.out.println(arr[ 0 ]); // prints the first element arr[ 2 ] = 10 ; // sets the third element to 10 🔁 2. Traversal of Arrays 🔹 Using For Loop: for ( int i = 0 ; i < arr.length; i++) { System.out.println(arr[i]); } 🔹 Using Enhanced For Loop: for ( int num : arr) { System.out.println(num); } ✍️ 3. Input in Arrays Scanner sc = new Scanner (System.in); int n = sc.nextInt(); int [] arr = new int [n]; for ( int i ...