Note that there are some explanatory texts on larger screens.

plurals
  1. POtrying to implement concept of LinkedList through java , but it is giving giving error at compile time?
    text
    copied!<p>I am trying simple linked list Collection program, but it is not giving me out put.<br> i created this stuff </p> <pre><code>import java.lang.*; import java.util.*; class Linkedlist { public static void main (String [] args) { LinkedList ll=new LinkedList (); System.out.println ("CONTENTS OF l1 = "+ll); System.out.println ("SIZE = "+ll.size ()); ll.add (new Integer (10)); ll.add (new Integer (20)); ll.add (new Integer (30)); ll.add (new Integer (40)); System.out.println ("CONTENTS OF ll = "+ll); System.out.println ("SIZE = "+ll.size ()); // retrieving data of ll using toArray () Object obj []=ll.toArray (); int s=0; for (int i=0; i&lt;obj.length; i++) { Integer io= (Integer) obj [i]; int x=io.intValue (); s=s+x; } System.out.println ("SUM USING toArray () = "+s); ll.addFirst (new Integer (5)); ll.addFirst (new Integer (6)); System.out.println ("CONTENTS OF ll = "+ll); System.out.println ("SIZE = "+ll.size ()); // retrieving data of ll using iterator () Iterator itr=ll.iterator (); int s1=0; while (itr.hasNext ()) { Object obj1=itr.next (); Integer io1= (Integer) obj1; int x1=io1.intValue (); s1=s1+x1; } System.out.println ("SUM USING iterator () = "+s1); ListIterator litr=ll.listIterator (); while (litr.hasNext ()) { Object obj2=litr.next (); System.out.print (obj2+","); } System.out.println ("\n"); while (litr.hasPrevious ()) { Object obj3=litr.next (); System.out.print (obj3+","); } System.out.println ("\n"); Object obj4=ll.get (2);// random retrieval System.out.println (obj4); } } </code></pre> <p>output is </p> <pre><code>Note: Linkedlist.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload