My java HW is to play around with some Stock Market data, read/write to files. I'm trying to throw this option (below) into the code and for some reason when I enter Y
, it doesn't enter the for-loop
. I can't figure out why. When I enter my Y
it just goes straight to the next chunk of the code and starts printing data to the screen (as it is supposed to do), without any of the below outputs/inputs.
System.out.println("Would you like to add items to the StockMarket data? (Y or N)");
Scanner input_check = new Scanner(System.in);
if(input_check.next() =="Y"){
//Scanner inp = new Scanner(System.in);
System.out.println("Enter name of stock (all caps): ");
//String input = inp.next();
names.add(input_check.next());
System.out.println("Enter date (MM/DD/YEAR) of stock data: ");
dates.add(input_check.next());
System.out.println("Enter the opening price: ");
opening.add(input_check.next());
System.out.println("Enter the closing price: ");
closing.add(input_check.next());
System.out.println("Enter the highest price: ");
highest.add(input_check.next());
System.out.println("Enter the lowest price: ");
lowest.add(input_check.next());
}