Classic bugs

From CodeCodex

Implementations[edit]

Java[edit]

Here some common mistakes : 1:

int x = 0;

for( x=0; x<10; x++ );{
 System.out.println("Print only once, why not 10 times ?");
 }

2:

boolean i = false;

if (i = false){
 System.out.println("Won't print, why ?");
 }

3:

public class WontCompile {
    public static void main(String[] args) {
        getInt(09);
    }

    private static void getInt(int i) {
        System.out.println(i);
    }
}

4:

// this don't do what it is supposed to do
void setIsDirtyData(boolean isdirtyData) {this.isDirtyData = isDirtyData;}