Java Keyword Byte

The Java Language reserves certain words that are not allowed to be used as variable names by Java developers. One of those reserved keywords is byte. The keyword byte is used to declare a field that can hold an 8-bit signed integer. Byte is also used to declare when a method returns a value of the primitive type byte.

If you attempted to use byte as a variable name, the compiler will complain. For example, take this variable declaration where I use byte.

int byte = 0;

This will results in the following error: Syntax error on token “byte” Invalid variable

The complete list of Java reserved keywords contains 50 keywords that can’t be used as variables.

Add a Comment

Your email address will not be published. Required fields are marked *