Online Java Compiler By
JavaTpoint.com
//import statements import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.reflect.Method; public class ReflectMethodequalsExample1 { public static void main(String[] args) { Method[] mthd = equalsDemoClass1.class.getMethods(); boolean isequal = mthd[0].equals(mthd[1]); System.out.println("Methods are " + (isequal?"equal.":"not equal.")); } } class equalsDemoClass1 { private String data1 ; private String data2 ; public equalsDemoClass1(){ } public equalsDemoClass1(String data1){ this.data1 = data1; } public String getData() { return data1; } public void setdata(String data1) { this.data1 = data1; } public String getData2() { return data2; } public void setdata2(String data2) { this.data2 = data2; } }
Output