I have a 2D string array that contains integers.
When I ask a user to add elements containing string and integers the program shows what the user added - but it is replaced by null
.
This is the code:
case 3:
count++;
System.out.println("Enter the type of the car: ");
car[count][0] = ky.next();
System.out.println("Enter the model of the car: ");
String addM = ky.next(); // integer
car[count][1] = addM;
System.out.println("Enter the price of the car: ");
String addP = ky.next(); // integer
car[count][1] = addP;
System.out.println("Enter the condition of the car: ");
String addC = ky.next();
car[count][3] = addC;
System.out.println("Enter the odemeter of the car (if it is new put it 0): ");
String addO = ky.next(); // integer
car[count][1] = addO1;
income -= Integer.parseInt(addP);
break;
and this what program shows:
Ford 2012 55000 new 0
Toyota 2012 60000 new 0
Honda 2011 25000 Used 6000
null null null null null
The last line is the data which the user should have added!
thanks a lot for helping.
car[count][1]
and it is not the value you immediately scanned, Check it please, Also what isky
? – Jigar Joshi 19 hours agocar[][]
array when displaying the output? – Andrzej Doyle 19 hours ago