Advertisement
KeeJayBe

PROG1: oef6

Nov 21st, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. /*
  2.  * KK    KK  JJJJJJJJJJ  BBBBBBBB
  3.  * KK  KK            JJ  BB      BB
  4.  * KKKK              JJ  BBBBBBBB
  5.  * KK  KK    JJ      JJ  BB      BB
  6.  * KK    KK    JJJJJJ    BBBBBBBBBB
  7.  *
  8.  * Copyright 2018 Jordy Van Kerkvoorde
  9.  */
  10. package h7;
  11.  
  12. import java.util.ArrayList;
  13. import java.util.List;
  14. import java.util.Scanner;
  15.  
  16. /**
  17.  *
  18.  * @author KeeJayBe
  19.  */
  20. public class Oefening6 {
  21.     public static void main(String[] args) {
  22.         Scanner s = new Scanner(System.in);
  23.         List<Integer> lijst = new ArrayList<>();
  24.         System.out.println("Geef een getal (-1 om te stoppen): ");
  25.         int getal = s.nextInt();
  26.         while(getal != -1){
  27.             lijst.add(getal);
  28.             System.out.println("Geef een getal (-1 om te stoppen): ");
  29.             getal = s.nextInt();
  30.         }
  31.         if(lijst.isEmpty()){
  32.             System.out.println("De lijst is leeg!");
  33.         }else{
  34.             System.out.println("Lijst: ");
  35.             for(int l: lijst){
  36.                 System.out.print(l + "\t");
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement