Your team is asked to develop ONE java program to compare th

Your team is asked to develop ONE java program to compare the memory efficiency between: java.util.ArrayList and java.util.Vector

Hint #1: You can modify Quiz1.java to create your solution.

Hint #2: Do you how to count? Do you know how to find the difference?

Hint #3: Ava and Eva share a bank account which has $100 in it. After Ava took some money out, the account balance is $92. After Eva took some money out, the account balance is $87. How much did Ava take out? How much did Eva take out?

screen shot of the program output

description of what the program does to compare the memory efficiency

/*
*Developed by: Raviteja Bagam, Sai Sandeep,
*Raghuvardhan, Rahul.
*This program shows the CPU time used to read numbers from QZ2Data.txt into an ArrayList.
*This program shows the CPU time used to read numbers from QZ2Data.txt into an integer array.
*/

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class Team5QZ1 {

   public static void main(String[] args) {
       // TODO Auto-generated method stub

       long startTime = System.currentTimeMillis();
      
       File file = new File(\"C:/Users/chandu/Desktop/QZ2Data.txt\");
      
       FileReader fileReader;
      
       try {
           fileReader = new FileReader(file);
      
       BufferedReader bufferedReader = new BufferedReader(fileReader);
      
       String currentLine = null;
      
       ArrayList list = new ArrayList();
      
           while((currentLine = bufferedReader.readLine())!=null)
           {
          
           String   temp[] = currentLine.trim().split(\"\\\\s+\");
          
               for(int i=0;i<temp.length;i++)
               {
              
                   list.add(temp[i]);
                  
               }
                  
           }
          
           System.out.println(\"CPU time used to read numbers from QZ2Data.txt into an ArrayList:\\t\"+(System.currentTimeMillis()-startTime));
          
           int[] input = new int[list.size()];
          
           for(int i=0;i<list.size(); i++)
           {
          
               input[i] = Integer.parseInt(list.get(i).toString());              
              
           }
          
           System.out.println(\"CPU time used to read numbers from QZ2Data.txt into an integer array:\\t\"+(System.currentTimeMillis()-startTime));
          
           bufferedReader.close();
       }
       catch (FileNotFoundException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
       }
       catch (IOException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
       }
      
   }
  
}

Solution

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class Team5QZ1 {

   public static void main(String[] args) {
       // TODO Auto-generated method stub

       long startTime = System.currentTimeMillis();
      
       File file = new File(\"C:/Users/chandu/Desktop/QZ2Data.txt\");
      
       FileReader fileReader;
      
       try {
           fileReader = new FileReader(file);
      
       BufferedReader bufferedReader = new BufferedReader(fileReader);
      
       String currentLine = null;
      
       ArrayList list = new ArrayList();
      
           while((currentLine = bufferedReader.readLine())!=null)
           {
          
           String   temp[] = currentLine.trim().split(\"\\\\s+\");
          
               for(int i=0;i<temp.length;i++)
               {
              
                   list.add(temp[i]);
                  
               }
                  
           }
          
           System.out.println(\"CPU time used to read numbers from QZ2Data.txt into an ArrayList:\\t\"+(System.currentTimeMillis()-startTime));
          
           int[] input = new int[list.size()];
          
           for(int i=0;i<list.size(); i++)
           {
          
               input[i] = Integer.parseInt(list.get(i).toString());              
              
           }
          
           System.out.println(\"CPU time used to read numbers from QZ2Data.txt into an integer array:\\t\"+(System.currentTimeMillis()-startTime));
          
           bufferedReader.close();
       }
       catch (FileNotFoundException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
       }
       catch (IOException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
       }
      
   }
  
}

Your team is asked to develop ONE java program to compare the memory efficiency between: java.util.ArrayList and java.util.Vector Hint #1: You can modify Quiz1.
Your team is asked to develop ONE java program to compare the memory efficiency between: java.util.ArrayList and java.util.Vector Hint #1: You can modify Quiz1.
Your team is asked to develop ONE java program to compare the memory efficiency between: java.util.ArrayList and java.util.Vector Hint #1: You can modify Quiz1.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site