So I have this:
String banana = "5";
int apple = 7;
result = banana * apple;
and I get this error:
not a statement bad operand types for binary operator '' first type: String second type: int*
How to I fix that?
So I have this:
String banana = "5";
int apple = 7;
result = banana * apple;
and I get this error:
not a statement bad operand types for binary operator '' first type: String second type: int*
How to I fix that?
String banana = "2";
int apple = 1;
int result = (Integer.valueOf(banana))*apple;
System.out.println("Result= " + result);
Try that ;)
Probably you did something like:
String banana = "3";
int apple = 2;
int result = banana*apple;
Just use Integer.parseInt()
:
int result = Integer.parseInt(banana)*apple;