I'm trying to read user input from the terminal and separate the input into separate arrays depending on if the user input is an integer, scanner, or a string. The terminal should keep asking the user for input until the user types "quit". Please help!
import java.util.*; public class arrayScanner { public static void main(String[] args) { ArrayList<Integer> intList = new ArrayList<Integer>(); ArrayList<Double> doubleList = new ArrayList<Double>(); ArrayList<String> otherList = new ArrayList<String>(); Scanner scanner = new Scanner(System.in); System.out.println("Enter an int, double, any random text, or type \"quit\" to end:" ); String input = scanner.nextLine(); if(scanner.nextLine() == "quit") { System.out.println("Integers: \n"); for(int i = 0; i < intList.size(); i++) { System.out.println("Integer list is" + intList.get(i)); } System.out.println("Doubles: \n"); for(int i = 0; i < doubleList.size(); i++) { System.out.println("Double list is" + doubleList.get(i)); } System.out.println("Other: \n"); for(int i = 0; i < otherList.size(); i++) { System.out.println("Other list is" + otherList.get(i)); } } else if(scanner.hasNextInt()) { intList.add(input); } else if(scanner.hasNextDouble()) { doubleList.add(input); } else if(scanner.hasNext()) { otherList.add(input); } } }