Avatar of chima
chima

asked on 

Java List

Hello,
I'm not familiar with ArrayList.  I'm currently looking/searching, yet if you know; I need for the ArrayList to hold three values.  They can all be strings.  Better yet; <String, String, double>   Is this possible with an ArrayList?;

package StudentClass;
import java.util.*; 

public class StudentRecords{
	
	public static void main(String[] args) {

		  ArrayList<String/*, String, String*/> StudRecord = new ArrayList<String/*, String, String*/>();

		  StudRecord.add("Will"/*, "reading", "A"*/);
		  /*obj.add("Harry");
		  obj.add("Chaitanya");
		  obj.add("Steve");
		  obj.add("Anuj");*/

		  //System.out.println("Currently the array list has following elements:"+obj);

		  /*Add element at the given index*/
		  //obj.add(0, "Rahul");
		  StudRecord.add("Justin"/*, reading, "B"*/);

		  /*Remove elements from array list like this*/
		  //obj.remove("Chaitanya");
		 // obj.remove("Harry");

		  System.out.println("Current array list is:"+StudRecord);

		  /*Remove element from the given index*/
		 // obj.remove(1);

		  System.out.println("Current array list is:"+StudRecord);
	   }

}

Open in new window

ProgrammingJava

Avatar of undefined
Last Comment
chima

8/22/2022 - Mon