I am trying to take input from a user and then sort that input into an array. The input must either be an int, double, or string. All I have right now is a loop asking for the input of the user.
How do I read/identify the input and store it into its proper ArrayList?
What I have so far:
import java.util.ArrayList;
import java.util.Scanner;
public class userInput {
public static void main(String [] args){
ArrayList<String> randomTextlist = new ArrayList<String>();
ArrayList<Double> doublelist = new ArrayList<Double>();
ArrayList<Integer> intlist = new ArrayList<Integer>();
boolean input = true;
Scanner scan = new Scanner(System.in);
while (input){
System.out.print("Input string, int, or double.");
intlist.add(scan.next());
}
Am I heading in the right direction? If so how do you suggest making sure that the input is put into their proper ArrayLists?