Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class Q1
- {
- public static void main(String[] args)
- {
- ArrayList<Integer> intList = new ArrayList<Integer>();
- Scanner kb = new Scanner(System.in);
- int userInput;
- do
- {
- System.out.println("Enter an integer (0 to exit)");
- userInput = kb.nextInt();
- if(userInput != 0)
- intList.add(userInput);
- }while(userInput != 0);
- System.out.println("Got it. You entered:");
- for(Integer num : intList )
- System.out.println(num);
- kb.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement