Java.lang Package Classes

Java Compiler - enable() Method



The java.lang.Compiler.enable() used to cause the Compiler to resume operation.

Syntax

public static void enable()

Parameters

No parameter is required.

Return Value

void type.

Exception

NA.

Example:

In the example below, the java.lang.Compiler.enable() method is used to cause the compiler to resume operation.

public class MyClass {
  public static void main(String[] args) {
    
    //check whether the compiler is enabled or not
    Compiler.enable();
    System.out.println("Compiler is enabled using enable() method.");

    Compiler.command("{java.lang.Byte.*} (compile)");
    
    //creating Byte object
    Byte b = new Byte("25");

    //printing hashCode of b
    System.out.println("hashCode of b is: " + b.hashCode());   
  }
}

The output of the above code will be:

Compiler is enabled using enable() method.
hashCode of b is: 25

❮ Java.lang - Compiler