Answers for "java get first element from arraylist"

13

java last element in array

arrayName[arrayName.length() - 1];
Posted by: Guest on March-05-2020
1

arraylist get last

E e = list.get(list.size() - 1);
Posted by: Guest on July-03-2020
0

java get first element from arraylist

import java.util.ArrayList;
public class FirstandLastElemets{
   public static void main(String[] args){
      ArrayList<String> list = new ArrayList<String>();
      //Instantiating an ArrayList object
      list.add("JavaFX");
      list.add("Java");
      list.add("WebGL");
      list.add("OpenCV");
      list.add("OpenNLP");
      list.add("JOGL");
      list.add("Hadoop");
      list.add("HBase");
      list.add("Flume");
      list.add("Mahout");
      list.add("Impala");
      System.out.println("Contents of the Array List: \n"+list);
      //Removing the sub list
      System.out.println("First element of the array list: "+list.get(0));
      System.out.println("Last element of the array list: "+list.get(list.size()-1));
   }
}
Posted by: Guest on December-05-2020
0

java list get first element

set.iterator().next();
Posted by: Guest on April-02-2020

Code answers related to "java get first element from arraylist"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language