I have been messing around to learn about java
and improving my simple calculator
I used a scanner Once which took doubles
And when i tried to use the Scanner again in later part of program to take another input, it gave me runtime inputmismatch error
Are we supposed to make different references for different inputs?
here is the code
import java.util.*; /* we used the premade classes and sub classes*/ public class spine { public static void main(String[] args) { System.out.println("enter the numbers followed with a String to end the cycle"); Scanner TAKER = new Scanner(System.in); //making object to acess Scanner clas List<Double> TAKER2 = new ArrayList<Double>(); //makiubg object of List class = new sub class arraylist try { //to catch input error while (TAKER.hasNext()) { TAKER2.add(TAKER.nextDouble()); //this is when i take the first input } } catch (InputMismatchException e) //this is the error we are catching { } //NOW WE TRANSFER THE NO FROM TAKER2 OBJECT TO AN REAL ARRAY Double array[] = new Double[TAKER2.size()]; //setting size of array TAKER2.toArray(array); //transfering the nos System.out.println("ok cool lets proceed"); System.out.println("enter 1 for addition, 2 - subtracton, 3 - multiplication, 4 - division."); int choices = TAKER.nextInt(); //this is when i take the 2nd input and this is where it crashes } }