Java Class - isLocalClass() Method
The java.lang.Class.isLocalClass() method returns true if and only if the underlying class is a local class.
Syntax
public boolean isLocalClass()
Parameters
No parameter is required.
Return Value
Returns true if and only if this class is a local class.
Exception
NA.
Example:
In the example below, the java.lang.Class.isLocalClass() method is used to check if the given class is a local class or not.
import java.lang.*; public class MyClass { public static void main(String[] args) { MyClass x = new MyClass(); Class cls = x.getClass(); //print the name of the class String name = cls.getName(); System.out.println("Class Name: " + name); //check if the class is a local class Boolean result = cls.isLocalClass(); System.out.println("Is it LocalClass?: " + result); } }
The output of the above code will be:
Class Name: MyClass Is it LocalClass?: false
❮ Java.lang - Class