forum

Home / DeveloperSection / Forums / for loop dead code in java

for loop dead code in java

Takeshi Okada 2111 21-Dec-2015
I'm getting a dead code warning in a for loop at i++. Why do I get that, and how do I solve this problem?

public static boolean Method(int p) {
    for(int i = 2; i < p; i++) {  // here is the problem, at i++
        if(p % i == 0);         
            return false;
    }
    return true;    
}

Updated on 21-Dec-2015

Can you answer this question?


Answer

1 Answers

Liked By