
public class HelloWorld { // class

	public static int value = 89;

	public static void main(String[] args) { // method

		// single-line comment
		// this line will display Hello World!
		System.out.println("Hello World!");

		/*
		 * this is a multiple-line commen if you have a long descriptions, use this
		 * comment
		 */
		System.out.println("Welcome to Java Programming.");

		/**
		 * this is javadoc
		 */

		// declare primitive data types variables
		int num = 8; // default type
		System.out.println(num);

		long bigNum = 9L;
		System.out.println(bigNum);

		double unitPrice = 19.99; // default type
		float totalPrice = 29.99F;
		System.out.println(unitPrice);
		System.out.println(totalPrice);

		// use + concatenator operator
		System.out.println("Unit Price: " + unitPrice);

		char color = 'G'; // single-quote to define char
		System.out.println(color);

		boolean flag = true;
		System.out.println(flag);

		System.out.println("Value: " + value);

		test(); // call the method
	}

	// define another method that try to access variables defined in main
	public static void test() {
//		System.out.println("Unit Price: " + unitPrice);
		System.out.println("Value: " + value);

		// increment
		value++; // value = value + 1
		System.out.println("Value: " + value);

		// decrement
		value--; // value = value - 1
		System.out.println("Value: " + value);
		
		value = value + 100;
		System.out.println("Value: " + value);	// 189
		
		// alternatively
		value += 100;
		System.out.println("Value: " + value);	// 289
		
		// pre-increment and post-increment
		int result = value++;	// post-increment
		System.out.println("Value: " + value);
		System.out.println("Value: " + value);
		
		result = ++value;		// pre-increment
		
	}

}
