Relative Content

Tag Archive for javafor-loop

How to create proper for loop in java

public class LoopExample { public static void main(String[] args) { int[] numbers = {1, 2, 3, 4, 5}; int sum = 0; for (int i = 0; i < numbers.length; i++) { sum += numbers[i]; } System.out.println(“Sum of numbers: ” + sum); } } What will be the output of the above Java program? Explain […]