Skip to content

Instantly share code, notes, and snippets.

@connorbrez
Created February 14, 2019 22:37
Show Gist options
  • Select an option

  • Save connorbrez/8e8cef62db35bebd8a8993e3f8ff2332 to your computer and use it in GitHub Desktop.

Select an option

Save connorbrez/8e8cef62db35bebd8a8993e3f8ff2332 to your computer and use it in GitHub Desktop.
// BOTH OF THESE STATEMENTS ARE EQUVILIANT
for(int i = 0; i<10;i++){
// nothing would run, because there is no code
};
for(int i = 0; i<10;i++); // ^ as said previous nothing runs because there is nothing to run
// your example below
{
System.out.println("10") // prints once because not in loop, but it tricks you because its
} // encapsulated with {}, usually this is done to help with readibility
// BOTH OF THESE STATEMENTS ARE EQUVILIANT
for(int i = 0; i<10;i++) System.out.println("10"); // this is okay because its on one line.
// Java may not like this but in javascript/typescript its oka
for(int i = 0; i<10;i++){
System.out.println("10")
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment