Online Java Compiler By
JavaTpoint.com
//import statements... import java.lang.*; import java.lang.reflect.Modifier; class Sample1 { Sample1(){ System.out.println("Sample1 Constructor calling"); } } public class ClassgetModifiersExample2 { public static void main(String[] args) { ClassgetModifiersExample2 obj = new ClassgetModifiersExample2(); Class class1 = obj.getClass(); Sample1 obj1 = new Sample1(); Class class2 = obj1.getClass(); int in = class1.getModifiers(); String rtvl = Modifier.toString(in); System.out.println("Class ClassgetModifiersExample2 Modifier = " + rtvl); int in2 = class2.getModifiers(); String rtvl2 = Modifier.toString(in2); System.out.println("Class Sample1 Modifier = " + rtvl2); } }
Output