Reputation: 373
I have a byte variable
byte A;
and the setters-getters methods
public void setA(byte A) throws NumberBelowEqualZeroException{
if(A > 0)
this.hoursPerWeek = hoursPerWeek;
throw new NumberBelowEqualZeroException();
}
public byte getWorkingHoursPerWeek(){
return hoursPerWeek;
}
when I try to set the variable in main
AClass.setA(0);
NetBeans complains with the message incompatible types. Possibly lossy conversion from int to byte. None of the above are int. I cannot understand what is going on. Should I convert byte type like byte A = new Byte(A)
? Thank you for your help.
Upvotes: 1
Views: 1949
Reputation: 17422
Now try
AClass.setA((byte)0)
It complains because constant 0 is an int
Upvotes: 3