`ArrayClass`

and `SingleLinkedList<Integer>`

.
See more:

l try to complies the code but there is an error and l did import to classes using both blue j and net bean compiler as bleo code

why there is an error?

**What I have tried:**

l did try to import both classes form java but the code wont compile and where is the error ??

Java

import java.text.DecimalFormat; import java.util.Random; public class AverageSpeedOfStructures { public static void main(String args[]) { //create a ArrayClass object ArrayClass array = new ArrayClass(1000000); //create a SingleLinkedList class object SingleLinkedList<Integer> sll = new SingleLinkedList<Integer>(); //create a Random object Random rand = new Random(); //create a DecimalFormat object DecimalFormat form = new DecimalFormat("##.####"); //declare the required variables to calculate and store double totalofArray = 0; double totalofSLL = 0; long arrInsert, arrDelete, arrSearch; long sllInsert, sllDelete, sllSearch; long start, end; //logic to find the time taken by insert method start = System.nanoTime(); for (int i = 0; i < 1000000; i++) { array.insert(rand.nextInt(1000)); } end = System.nanoTime(); arrInsert = Math.abs(start - end); //logic to find the time taken by search method start = System.nanoTime(); array.search(300); end = System.nanoTime(); arrSearch = Math.abs(start - end); //logic to find the time taken by delete method start = System.nanoTime(); array.delete(300); end = System.nanoTime(); arrDelete = Math.abs(start - end); //average time taken by the ArrayClass using arrays totalofArray = (arrInsert + arrDelete + arrSearch) / 3.0; // Single LinkedList speeds //logic to find the time taken by insert method start = System.nanoTime(); for (int i = 0; i < 1000000; i++) { sll.listInsert(rand.nextInt(1000)); } end = System.nanoTime(); sllInsert = Math.abs(start - end); //logic to find the time taken by search method start = System.nanoTime(); sll.listSearch(300); end = System.nanoTime(); sllSearch = Math.abs(start - end); //logic to find the time taken by delete method start = System.nanoTime(); sll.listRemove(300); end = System.nanoTime(); sllDelete = Math.abs(start - end); //average time taken by the singly linked list totalofSLL = (sllInsert + sllDelete + sllSearch) / 3.0; //print the ratio of speeds System.out .println("The ratio of averge speed of an Unsorted-Optimized" + " array structure \nto the average speed of a" + " Singly Linked List structure is: \n" + form.format(totalofArray) + " : " + form.format(totalofSLL)); } }

why there is an error?

l did try to import both classes form java but the code wont compile and where is the error ??

Comments

phil.o
17-Oct-18 17:29pm

Which error? Compilers are usually verbose about the reasons why they cannot do their job; we would need to have the error message.

Patrice T
17-Oct-18 19:52pm

and you plan to tell the error message ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject,
20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8
+1 (416) 849-8900