How to detect Duplicate code in Java?
<p>I want to know that how to detect duplicate code in java but i also know that there are several types 
of tools are present like CPD and Simian. But, i am not interested to use those tools.However,if i look 
at a code i can easily find out that where the duplicate code are present but how the system will 
know where the duplicate code is present. If any algorithm or any technique present then please tell 
me.Here's my code:</p>

<pre><code>public class Duplicate {

    float b,c;
    static float res1,res2;

    static float add(float p,float q){
        return p+q;
    }
    static float sum(float p,float q){
        float t;
        t=p+q;
        return t;
    }

    public static void main(String[] args) {
        System.out.println("Duplicate Method used");
        res1=add(5,6);
        System.out.println("1st Method is called="+res1);
        res2=sum(5,6);
        System.out.println("2nd Method is called="+res2);
    }

}
</code></pre>

<p>In this code i am using 2 method as add and sum but both are doing the same work.Here, the programmer
can look at the code and he can easily find out but how the system can find out.</p>
