Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.LinkedList;
- import java.util.Random;
- public class LinkedListApp {
- public static void main(String[] args) {
- int maxNumbers = 10;
- LinkedList<Integer> firstList = new LinkedList<>();
- //linked list of postive integer randon numbers
- Random randomizer = new Random();
- for (int iCount = 0; iCount< maxNumbers; iCount++){
- firstList.add(randomizer.nextInt(100));
- }
- //second linked list with the first's integers and removal first linked list's items
- LinkedList<Integer> secondList = new LinkedList<>();
- for (Integer num :
- firstList) {
- secondList.add(num);
- firstList.remove(num);
- }
- //display second linked list items
- String comma = "";
- for (Integer num :
- secondList) {
- System.out.print(comma + num);
- comma = ", ";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement