Thursday, February 25, 2010

Best Practice of Java Array Declaration

To declare a array in Java, you have following options:
  1. dataType[] variableName;
  2. dataType variableName[];
  3. dataType []variableName;
The 1st is clearly related to how Java actually works, and you can read it as "dataType array variableName".

The conclusion is:
  • dataType[] variableName;
  • dataType[][]...[] arrayName;

Wednesday, February 3, 2010

IE8 user agent string

IE8 have 3 kinds of browser mode, but give different user agent string

IE7 mode give you Mozilla/4.0 (compatible; MSIE 7.0; ...;)
IE8 mode give you Mozilla/4.0 (compatible; MSIE 8.0; ...; Trident/4.0; ...;)
IE8 compat view mode give you Mozilla/4.0 (compatible; MSIE 7.0; ...; Trident/4.0; ...;)

Trident/4.0
is the important string to determine the real mode and version of IE8.

Saturday, January 23, 2010

Java Operators

.         []           ()
++        --           !            ~
*          /           %
+         -
<<        >>           >>>         <<<
<         >            <=           >=
==        !=
&         |
^
&&
||
?:
=

Java Data Types

Primitive Data Types
  • boolean (true, false)
  • char (8 bits)
  • byte (8 bits)
  • short (16 bits)
  • int (32 bits)
  • long (64 bits)
  • float (32 bits)
  • double (64 bits)
Reference Variables vs. Primitive Variables
  • Primitive variables are variables with primitive data types. They store data in the actual memory location of the variable is.
  • Reference variables are variables that stores the address in the memory location. It points to another memory location of the actual data is.

Tuesday, January 19, 2010

My First Java Program

public class Hello {
    /**
     * My first Java program
     */
    public static void main(String[] args) {
        //prints the string "Hello world!" on screen
        System.out.println("Hello world!");
    }
}


Error Types
  • Syntax errors
  • Run-time errors
Java Comments
  • C++ Style Comments
  • C-Style Comments
  • Special Javadoc Comments

About Java

What is Java Technology?
  • A programming language
  • A development environment
  • An application environment
  • A deployment environment
Some Features of Java
  • The Java Virtual Machine (JVM)
  • Garbage Collection
  • Code Security
Java, JavaScript, HTML, XHTML, AJAX, CSS, etc.