1. Engineering
  2. Computer Science
  3. create intcoll4 and run our intcoll4client using intcoll4 in this...

Question: create intcoll4 and run our intcoll4client using intcoll4 in this...

Question details

Create intcoll4 and run our intcoll4client using intcoll4.

In this 4th version, intcoll4, the integers in a collection are stored in a linked list whose name is the private member c (using the inner class ListNode). Also, how many is still a private member.

// The inner class for ListNode

      private class ListNode


           private int info; private ListNode link;

           public ListNode()  { info=0; link=null;}

public ListNode(int i, ListNode p) {info=i; link=p;}


// FILE NAME    : LLIntcollTest.java
// DESCRIPTION  : This file tests Intcoll4 - the linked list version of Intcoll.

import java.util.*;
import java.io.*;

public class LLIntcollTest
   public static void main(String[] args)
      System.out.println("Enter # of random integers to be generated");
      Scanner blackboard=new Scanner(System.in);
      int n=blackboard.nextInt(); 
      Intcoll4 LL=new Intcoll4(n); 
      Random gen=new Random(); long lapse=0, begin, end; int k=0;
      while (k<n) 
         int i=5*(gen.nextInt(n)+1); 
      System.out.println("The # of integers in LL is "+LL.get_howmany());
      System.out.println("Time in milliseconds "+lapse);
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution