eightmoons

LInkedLIstApp v1.1.java

Oct 26th, 2020
69
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.LinkedList;
  2. import java.util.Random;
  3.  
  4. public class LinkedListApp {
  5.  
  6.     public static void main(String[] args) {
  7.         int maxNumbers = 10;
  8.         LinkedList<Integer> firstList = new LinkedList<>();
  9.         //linked list of postive integer randon numbers
  10.         Random randomizer = new Random();
  11.         for (int iCount = 0; iCount< maxNumbers; iCount++){
  12.             firstList.add(randomizer.nextInt(100));
  13.         }
  14.         //second linked list with the first's integers and removal first linked list's items
  15.         LinkedList<Integer> secondList = new LinkedList<>();
  16.         for (Integer num :
  17.                 firstList) {
  18.             secondList.add(num);
  19.             firstList.remove(num);
  20.         }
  21.  
  22.         //display second linked list items
  23.         String comma = "";
  24.         for (Integer num :
  25.                 secondList) {
  26.             System.out.print(comma + num);
  27.             comma = ", ";
  28.         }
  29.  
  30.     }
  31.  
  32. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×