I don't know where did I do wrong here, but it is a compiler error. I was try to create an Arraylist that can store the double value. For some reason, I got a compiler error when I try to create an Arraylist. By the way, the assignment specifically ask to use arraylist from java utility library.
Here is the code:
import java.util.Scanner;
import java.util.ArrayList;
public class StudentList
{
public static void pause()
{
try
{
System.out.print("Press <Enter> to continue...");
System.in.read();
}
catch (Exception e)
{
System.err.printf("Error %s%c\n",e.getMessage(),7);
}
}
public static void main(String[] args)
{
ArrayList< String > studentFName = new ArrayList< String >();
ArrayList< String > studentLname = new ArrayList< String >();
ArrayList< String > major = new ArrayList< String >();
ArrayList< double > gpa = new ArrayList< double >();
Scanner keyBd = new Scanner( System.in );
char selection;
do{
System.out.println("\n--------------");
System.out.println("1. Add Student");
System.out.println("2. Remove Studnet");
System.out.println("3. Find Studnet");
System.out.println("4. Display Studnet");
System.out.println("5. Display All Studnet");
System.out.println("6. Exit\n");
System.out.print ("Selection: ");
selection = keyBd.next().charAt(0);
switch (selection){
case '1':
pause();
break;
case '2':
pause();
break;
case '3':
pause();
break;
case '4':
pause();
case '5':
pause();
break;
case '6':
break;
default :
System.out.println("Invalid Selection");
}//end switch
}while( selection != '6');
}//end main()
}
The compiler error message is
StudentList.java:25: error: unexpected type
ArrayList< double > gpa = new ArrayList< double >();
^
required: reference
found: double
StudentList.java:25: error: unexpected type
ArrayList< double > gpa = new ArrayList< double >();
^
required: reference
found: double
2 errors
Thank you so much.