Arrays in Java
Arrays are used to store multiple values of the same data type in a single variable. You can access individual elements of an array using an index.
Example code:
csharp
int[] numbers = {1, 2, 3, 4, 5};
System.out.println(numbers[0]); // prints 1
String[] names = {"Alice", "Bob", "Charlie"};
System.out.println(names[1]); // prints "Bob"
No comments:
Post a Comment