java last element in array
arrayName[arrayName.length() - 1];
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));
}
}
java list get first element
set.iterator().next();
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us