Question
I have this code. But when i run it, it says Exception in thread main java.lang.NullPointerException. Can someone please fix this and print the updated
I have this code. But when i run it, it says Exception in thread "main" java.lang.NullPointerException. Can someone please fix this and print the updated fixed code solution?
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.lang.instrument.Instrumentation; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList;
public class ArrayLinkedListExamples { private static Instrumentation instrumentation; public static void main(String args[]) throws IOException {
// Creating an empty Array and Linked list ArrayList
BufferedReader br = new BufferedReader(new FileReader("C:midData.csv"));
String strLine; //Read File Line By Line while (!((strLine = br.readLine()) == null)) { arraylist.add(strLine); linkedlist.add(strLine); } br.close();
long size = instrumentation.getObjectSize(arraylist); System.out.println("Bytes used by Arraylist object: " + size); size = instrumentation.getObjectSize(linkedlist); System.out.println("Bytes used by Arraylist object: " + size);
long startl = 0, countl = 0; for (Iterator
long timel = System.nanoTime() - startl; long starta = 0, counta = 0; for (Iterator
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started