Skip to content

Commit

Permalink
Loops class
Browse files Browse the repository at this point in the history
  • Loading branch information
kacper-cholewinski committed Oct 26, 2024
1 parent e4bd271 commit 89abd48
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions kodilla-intro/src/main/java/Loops.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
public class Loops {
public static void main(String[] args) {
for (int i = 0; i <= 10; i++) {
System.out.println(i);
}

String[] names = new String[] {"Zygfryd", "Gwidon", "Florentyna"};

for (int i = 0; i < names.length; i++) {
System.out.println(names[i]);
}

System.out.println(sum(new int[] {1, 1, 2, 3, 5, 8, 13}));

int i = 0;
while (i <= 10) {
System.out.println(i);
i++;
}
}

private static int sum(int[] numbers) {
int sum = 0;

for (int i = 0; i < numbers.length; i++) {
sum += numbers[i];
}

return sum;
}
}

0 comments on commit 89abd48

Please sign in to comment.