List<String> ll = new LinkedList<String>("String1","String2",...);
I want something like above. Is the above line possible in java...?
Like arrays, Linked List is a linear data structure. Unlike arrays, linked list elements are not stored at the contiguous location, the elements are linked using pointers as shown below. In Java, LinkedList can be represented as a class and a Node as a separate class.
LinkedList. contains() method is used to check whether an element is present in a LinkedList or not. It takes the element as a parameter and returns True if the element is present in the list.
not directly but
List<String> ll = new LinkedList<String>(Arrays.asList("String1","String2",...));
is what you're looking for
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With