004-003-004
Element Access: Retrieving Values from Arrays
Easy
Problem Description
Array Element Access
Array elements are accessed using indices (subscripts).
Basic Access
int[] arr = {10, 20, 30, 40, 50};
System.out.println(arr[0]); // 10 (first element)
System.out.println(arr[2]); // 30 (third element)
System.out.println(arr[4]); // 50 (last element)Learning Points
- Index starts from 0
- Last element index is array length - 1
- Out-of-bounds access causes errors
Test Cases
※ Output examples follow programming industry standards
Input:
10 20 30 40 50 0
Expected Output:
10
Input:
10 20 30 40 50 2
Expected Output:
30
Input:
10 20 30 40 50 4
Expected Output:
50
❌ Some tests failed
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here
sc.close();
}
}
0 B / 5 MB
You have 6 free executions remaining
