Simple Java Program
Hi there,
I have the following program:
public class e1
{
public static void main (String[] args){
byte a = 1;
while (a<9)
{
System.out.println(a);
a++;
}
}
}
When I try and compile the program I get the following error:
C:\Java\bookwork>javac e1.java
e1.java:8: possible loss of precision
found : int
required: byte
a = a * 2;
^
1 error
I know that changing the variable "a" from byte to int fixes this problem but how can I make this code work leaving "a" as a byte?
I hope someone can help
Kindest Regards
WargeMaster
|