10) Write a complete Java program that prompts the user to create a list of the following types: String, Integer and Double. Your program should create the appropriate list type as determined by the user.
What will be an ideal response?
```
import java.util.*;
public class FunWithLists
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int listChoice;
ArrayList> list;
String listElement;
//Display a list of list choices for the user
System.out.println("Enter the number of the list you wish to create:");
System.out.println(" 1. String");
System.out.println(" 2. Integer");
System.out.println(" 3. Double\n\n");
listChoice = sc.nextInt();
switch(listChoice)
{
case 1:
list = new ArrayList
break;
case 2:
list = new ArrayList
break;
case 3:
list = new ArrayList
break;
default:
System.out.println("Invalid choice");
break;
}
}
}
```
You might also like to view...
What clause of the ISO 12207 standard outlines the measurement process?
A. 6.3.4 B. 6.3.5 C. 6.3.6 D. 6.3.7
A JAD session involves:
A) casual planning, since the interaction between users is when the activity occurs in a creative fashion. B) using a session leader that has excellent communication skills. C) having a systems analyst as a session leader. D) note-taking by all the individuals within the session.
____ solve the problem of overlapping shapes without merging them.
a. Stacks b. Fills c. Layers d. Clusters
What are abstract methods? Describe the circumstances in which an abstract method would be appropriate.
What will be an ideal response?