byte keyword in java

The byte keyword is used to declare variable as a numeric type.

A byte value can hold an 8-bit integer number which ranges from -128 to 127.

For example:
byte day = 6;

The byte keyword can be used to declare a type of a method parameter as below:

  1. public void displayDayOfWeek(byte day) {
  3.     if(day == 3){
  5.                    System.out.println("Tuesday");
  6.                 }
  8. }
public void displayDayOfWeek(byte day) {

    if(day == 3){



The byte keyword can also be used to declare return type of a method as below:

  1. public byte getDayOfWeek(String day) {
  3. if(day.equals("Monday")){    
  5.                               return 2;
  6.                         }
  7. }
public byte getDayOfWeek(String day) {


                              return 2;

About the Author

Karibasappa G C (KB)
Founder of
I love Java and open source technologies and very much passionate about software development.
I like to share my knowledge with others especially on technology 🙂
I have given all the examples as simple as possible to understand for the beginners.
All the code posted on my blog is developed,compiled and tested in my development environment.
If you find any mistakes or bugs, Please drop an email to

Connect with me on Facebook for more updates

Share this article on