Java:
[first line:]
public class Main {
public static void main(String[] args) {
[Link]("hello, world!");
}
}
public class main { = class called main which is public so any other classes can
access it
public static void main(String[] args) { = entry point of the java program:
public = anyone can access it
static = you can run this method without creating
an instance of Main.
void = this method doesn't return any value.
main is the name of the method.
[variables and types:]
primitive data types: represents raw values
list of primitives in java: byte (number, 1 byte)
short (number, 2 bytes)
int (number, 4 bytes)
long (number, 8 bytes)
float (float number, 4 bytes)
double (float number, 8 bytes)
char (a character, 2 bytes)
boolean (true or false, 1 byte)
[Numbers:]
declare and assign number: int myNumber;
myNumber = 5;
or combine them: int myNumber = 5;
define double floating point number: double d = 4.5;
d = 3.0;
using float: float f = (float) 4.5;
shorter way using float = float f = 4.5f; // (f is a shorter way of casting float)
[characters and strings:]
chars = characters
syntax for chars: char c = 'g';