What is bytecode in Java?

Bytecode is the low level, compact code that javac makes from your source code. It is saved in .class files, and it is not machine code. The JVM runs it, by interpreting it and by compiling the hot parts to machine code with the JIT compiler.

You can look at the bytecode with the javap tool:

public class Add {
    static int add(int a, int b) {
        return a + b;
    }
}
Terminal

$ javac Add.java
$ javap -c Add | sed -n '1,14p'
Compiled from "Add.java"
public class Add {
public Add();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return

static int add(int, int);
Code:
0: iload_0
1: iload_1
2: iadd
3: ireturn

The lines like iload_0 and iadd are bytecode instructions. See What is Java?.


Learn more about the similar topics:
Tutorials
Java Introduction
What is Java? JDK, JRE and JVM
Java Install and Setup
Your First Java Program: Hello World
Java Syntax
Java Comments
Java Cheat Sheet
Exercises & Assignments
No Content Found.
Interview Questions & Answers
What is the difference between Java and JavaScript?
What is Java?
What are the main features of Java?
What is the difference between JDK, JRE and JVM?
Why is Java platform independent?
What is bytecode in Java?
Why is the main method public static void in Java?