Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class NegativeTall {
- public static void main(String[] args) {
- int[] Tallrekke = {1, 4, 5, -2, -4, 6, 10, 3, -2};
- int negativeTall = 0;
- for (int i : Tallrekke)
- {
- if (i < 0) negativeTall++;
- }
- System.out.println("Antall negative tall: " + negativeTall);
- // Antall negative tall: 3
- // denne fungerer også...
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement