Java byte type with example

The byte data type of Java

Java has eight types of primitive data types to store data in the Java programs. The byte is one of the primitive data types in Java.

Few main points about Java byte data type:

  • The byte takes eight bits or one byte of signed memory.
  • Byte Is a numeric type.
  • The Default value of the byte variable is 0.
  • The Minimum value of the byte type can be -128.
  • The Maximum value of the byte java type can be 127.

byte data type example

The following example declares and uses the byte Java data type variable. The variable is assigned a value and then printed on the screen by using the System.out.println.

See graphic of above example


As you run the code the output will be:

10

In the above example, you can see the byte variable is declared and value can be assigned later or at the time of declaration as well.

The java byte type of variable can be used in the array index, for instance, that takes four times less space than the java integers.

Also see Java data types

Was this article helpful?

Related Articles

Leave A Comment?