This post will be filled with many small pieces of code that are of great importance in the Java world. Even though these may seem incredibly basic, most people have the hardest time wrapping their mind around the most simplistic pieces. That's where this post comes in, it will help you get your feet off the ground.
Variables:
Variables store data for you, like boxes when you have too much crap lying around the house. Variables are set up as so:
[Object Type] [Object Name] [Optional =] [Optional Data];
Examples:
//Initialize an Integer
int i = 0;
//Initialize a String
String message = "Hello World.";
//Initialize a Char
char letter = 'A';
If-Statements:
If statements are what makes your program... a program. It allows you to actually do stuff depending on variables.
For Loop:
for (int i = 0; i <n; i++)
{
//code goes here
}
While Loop:
Print Line:
System.out.println("Hello World.");
-Gandolf
P.S. If you guys just post your random Java code, I will insert them in a category. I'll also add definitions under the pieces of code a little later.