If statement Becareful !!!
Becareful!!, this is what i encounter today, what a stupid “If statement” i created….ai..do you seen what error below?
1 2 3 4 5 | if(this.putNode(estraierFts, ftsUrlSync)); { //delete record after update ftsUrlSyncBO.deleteFtsUrlSync(ftsUrlSync.getId()); } |
Above statement compile successfully in Java, what i trying want to do is , when condition true, it will delete my records. However with above statement, it will delete my record no matter condition true or false. This is funny, did you notice what error above? …. haha notice carefully , “;” after a “If statement”..what a stupid mistake i made.. TT…. my eyes are blur…take a rest first
Correct statement should be following
1 2 3 4 5 | if(this.putNode(estraierFts, ftsUrlSync)) { //delete record after update ftsUrlSyncBO.deleteFtsUrlSync(ftsUrlSync.getId()); } |
That’s really thnkniig out of the box. Thanks!
thats why it will be a good idea for the opening brace in an if-block is placed next to the closing brace of the condition.
Code formatting really helps reduce bugs
totally agree with your point, however different people may have different code formatting style (because they learn from different ways)
Wow Cool !
Super Man
Nice Site