Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.PrintStream;
- import type.lib.*;
- public class lab5
- {
- public static void main(String args[])
- {
- PrintStream output = new PrintStream(System.out);
- Scanner input = new Scanner(System.in);
- output.println("Initializing...\n");
- List<Integer> bag = new ArrayList<Integer>();
- Iterator<Integer> itr = bag.iterator();
- output.println("Enter any positive integer. Enter -1 to exit");
- for(int userIn = input.nextInt(); userIn>=0 ; userIn = input.nextInt())
- {
- bag.add(userIn);
- }
- output.println(bag);
- bag.add(1);
- output.println(bag);
- int totalSum = 0;
- for (;itr.hasNext();)
- {
- itr.next();
- output.println(bag);
- }
- output.println(totalSum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement