The get() method of Java AbstractSequentialList class

Java 8ProgrammingObject Oriented Programming

The get() method of the AbstractSequentialList class is used to display the element at the specified position in this list.

The syntax is as follows

public E get(int index)

Here, index is the location from where you want to get the element.

To work with the AbstractSequentialList class in Java, you need to import the following package

import java.util.AbstractSequentialList;

The following is an example to implement AbstractSequentialList get() method in Java

Example

 Live Demo

import java.util.LinkedList;
import java.util.AbstractSequentialList;
public class Demo {
   public static void main(String[] args) {
      AbstractSequentialList<Integer> absSequential = new LinkedList<>();
      absSequential.add(10);
      absSequential.add(25);
      absSequential.add(60);
      absSequential.add(70);
      absSequential.add(195);
      System.out.println("Elements in the AbstractSequentialList = "+absSequential);
      System.out.println("Element at index 2 = " + absSequential.get(2));
      System.out.println("Element at index 4 = " + absSequential.get(4));
   }
}

Output

Elements in the AbstractSequentialList = [10, 25, 60, 70, 195]
Element at index 2 = 60
Element at index 4 = 195
raja
Published on 26-Mar-2019 10:11:01
Advertisements