Java.lang.Compiler.enable() 方法

描述

java.lang.Compiler.enable() 方法使编译器恢复运行。


声明

以下是 java.lang.Compiler.enable() 方法的声明。

public static void enable()

参数

NA


返回值

此方法不返回任何值。


异常

NA


示例

下面的例子展示了 java.lang.Compiler.enable() 方法的使用。

package com.tutorialspoint;

import java.lang.*;

public class CompilerDemo {

   public static void main(String[] args) {

      // checking if compiler is enabled or not        
      Compiler.enable();
      System.out.println("Compiler Enabled...");                          
      Compiler.command("{java.lang.Integer.*}(compile)");

      Integer i = new Integer("50");
    
      // returns a hash code value
      int retval = i.hashCode();
      System.out.println("Value = " + retval); 
   }
} 

让我们编译并运行上面的程序,这将产生下面的结果 −

Compiler Enabled...
Value = 50