两种方法在语法上是否相等 [英] Whether two methods are equal syntactically

查看:84
本文介绍了两种方法在语法上是否相等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么知道两个函数在语法上是否相等?
有帮助吗?

How can i know whether two functions are syntactically equal?
Any help?

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");
}


根据语法,method1和method2相等,但是它不等于我.


According to syntax method1 and method2 are equal but its not giving me equal. Any way around??

推荐答案

两个getSource()方法返回的值是什么?您确定它们一个字符一个字符吗?
What are the values returned by the two getSource() methods? Are you sure they are equal character by character?


getSource()的返回值是字符串.我不是说它们一个字符一个字符.实际上,我使用DesiredMethod.getSource()以字符串形式获取该方法的代码.而且我不得不比较两种方法在语法上是否相等.尽管两种方法在语法上相等,但它们并没有成为现实.由于空格而相等.为了消除这个空白问题,我将所有空格替换为没有空格,这样做可以删除空格,但是在有Enter的地方,空格不能删除,字符串也不会相等.因此,有任何建议可以解决此问题?
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??


这篇关于两种方法在语法上是否相等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆