Click here to Skip to main content
16,011,611 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i know whether two functions are syntactically equal?
Any help?
Java
String class1=DesiredMethod.getSource();
String method1=class1.replaceAll(" ","");
System.out.println(method1);
String class2=DesiredMethod1.getSource();
String method2=class2.replaceAll(" ","");
System.out.println(method2);
if(  method1.equalsIgnoreCase(method2))
{
     System.out.println("Both functions are equal");
}

According to syntax method1 and method2 are equal but its not giving me equal. Any way around??
Posted
Updated 25-May-10 8:00am
v3

What are the values returned by the two getSource() methods? Are you sure they are equal character by character?
 
Share this answer
 
the return value of getSource() is string.And i am not saying that they are equal character by character.I am saying that they are syntactically equivalent.Actually i get code of the method in string by using DesiredMethod.getSource().And i have to compare that whether two methods are syntactically equivalent or not.Inspite of the fact that two methods are equal syntactically they are not are becoming equal due to white spaces. To remove this issue of white spaces i replace all spaces with no space, by doing this i get spaces removed but where there is enter, spaces are not remove and strings are not becoming equal.So any suggestion to get this of this issue??
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900