trying to implement concept of LinkedList through java , but it is giving giving error at compile time?

前端 未结 3 1297
故里飘歌
故里飘歌 2021-01-24 21:52

I am trying simple linked list Collection program, but it is not giving me out put.
i created this stuff

import java.lang.*;  
import java.util.*;  

cla         


        
3条回答
  •  滥情空心
    2021-01-24 22:15

    I executed your program through eclipse :

    Just use LinkedList instead of just LinkedList. No Warnings.

    Output =>

    CONTENTS OF l1 = []
    SIZE = 0
    CONTENTS OF ll = [10, 20, 30, 40]
    SIZE = 4
    SUM USING toArray () = 100
    CONTENTS OF ll = [6, 5, 10, 20, 30, 40]
    SIZE = 6
    SUM USING iterator () = 111
    6,5,10,20,30,40,
    
    Exception in thread "main" java.util.NoSuchElementException
        at java.util.LinkedList$ListItr.next(Unknown Source)
        at com.Linkedlist.main(Test.java:46)
    

提交回复
热议问题