java - Setting byte field in an object -
i have simple program below:
class serializationbox implements serializable { private byte serializableprop = 10; public byte getserializableprop() { return serializableprop; } public void setserializableprop(byte serializableprop) { serializableprop = serializableprop; } } public class serializationsample { /** * @param args */ public static void main(string args[]) { serializationbox serialb = new serializationbox(); serialb.setserializableprop(1); // here error } }
at indicated place in code error "the method setserializableprop(byte) in type serializationbox not applicable arguments (int)".
i believed per link http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html , allowed pass -128 127 arguement.
please let me know missing?
you have cast integer byte
:
serialb.setserializableprop((byte) 1);
notes:
when do
private byte serializableprop = 10;
10
integer, not binary number. specify number binary have use following syntax:private byte serializableprop = 0b10; ^^
Comments
Post a Comment