Java Arrays Real-Life Examples
📦 Java Arrays – Real-Life Examples Arrays are widely used in Java to store collections of similar data. Here are some practical real-life examples of arrays. 1️⃣ Store Student Marks
1 2 3 4 5 6 7 8 9 10 11 | public class Main { public static void main(String[] args) { int[] marks = {85, 90, 78, 92, 88}; // Marks of 5 studentsint sum = 0; for (int mark : marks) { sum += mark; } double average = sum / (double) marks.length; System.out.println("Average marks: " + average); } } |
📌 Output:...
