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
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.