Java default Integer value is int
- by Chris Okyen
My code looks like this
import java.util.Scanner;
public class StudentGrades {
public static void main(String[] argv)
{
Scanner keyboard = new Scanner(System.in);
byte q1 = keyboard.nextByte() * 10;
}
}
It gives me an error "Type mismatch: cannot convert from int to byte." Why the heck would Java store a literal operand that is small enough to fit in a byte,. into a int type? Do literals get stored in variables/registers before the ALU performs arithmatic operations.