Skip to content

Instantly share code, notes, and snippets.

@josephkandi
Last active May 3, 2016 08:35
Show Gist options
  • Save josephkandi/e4687e764c6fc774129583c0fe1237a8 to your computer and use it in GitHub Desktop.
Save josephkandi/e4687e764c6fc774129583c0fe1237a8 to your computer and use it in GitHub Desktop.
//This is an example comment, notice how the compiler ignores it
//There are two slashes(//) at the beginning of the line
//The slashes denote that this is a comment
public class CommentsDemo {
public static void main(String[] args) {
//System.out.println("I will show when am commented out");
//Run it, try removing the two slashes and run again
/*
This is a block comment, its very useful
when describing in detail what the code is doing
Am going to use it below to describe what the program is doing
*/
/*
int[] numbers = {1,2,3,4,5,6,7,8,9,10};
int sum = 0;
for(int number : numbers){
sum = sum + number;
}
System.out.println("Total " + sum);
*/
//Uncomment the above block comment and Run again.
//Observe how block comments are useful for commenting out
//a huge portion of code. This is useful for debugging
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment