Archive:Java/Programming tips: Difference between revisions

wikademia>Sebmol
m Reverted edits by Stinky sock (Talk) to last version by JWSchmidt using rollback
wikademia>Zchenyu
Line 79: Line 79:
==Good Comments==
==Good Comments==
Good comments can help make your code look neat. They should tell what you are doing OVERALL, not what you are doing on each line. For example, you can comment an if statement if it is kind of complex, but not every statement has to be commented:
Good comments can help make your code look neat. They should tell what you are doing OVERALL, not what you are doing on each line. For example, you can comment an if statement if it is kind of complex, but not every statement has to be commented:
<pre>
<pre>
if(i1 == i2 && i1 == i3)//Check if i1 is equal to i2 and i3
if(i1 == i2 && i1 == i3) // Check if i1 is equal to i2 and i3
{
{
   System.out.println("Yes");//Print Yes to the command line
   System.out.println("Yes"); // Print Yes to the command line
   i1++;//Add 1 to i1
   i1++; // Add 1 to i1
}
}
</pre>
</pre>
This is an example of a '''bad''' use. People who don't know Java should NOT be looking at your code!
This is an example of a '''bad''' use. People who don't know Java should NOT be looking at your code!




<br><br><hr>
 
 


{{1lvlnav|[[Topic:Java|Java]]|[[Important Java Classes]]|[[Java/Fundamental Exercises|Fundamental Exercises]]}}
{{1lvlnav|[[Topic:Java|Java]]|[[Important Java Classes]]|[[Java/Fundamental Exercises|Fundamental Exercises]]}}
[[Category:Java]]
[[Category:Java]]