Software Engineers Handbook/Language Dictionary/Java


Here is the Java wikipedia entry.


Java is a full, procedural, object-oriented language.

Execution Entry PointEdit

public static void main(String args[])
    // some functionality here

General SyntaxEdit

The typical statement is completed by a semi-colon. For the assignment of b to a use:

a = b;


// this is an inline comment.  Everything after the // is a comment.

Block comments are specified by a starting /* and ending */ They can span multiple lines.

 * this is a block comment 

Variable DeclarationsEdit

int x = 9;
Integer y = new Integer(4);

Method Declaration/ImplementationEdit

// declaration
private return_type class_name::function_name(argument_1_type arg_1_name, 
                          argument_2_type arg_2_name, 
                          default_argument_type default_arg_name)
{ // implementation
    // work with arg_1_name, arg_2_name, and default_arg_name
    // depending on the argument types the variables are passed by 
    //   value, reference, or are constant
    // don't forget to return something of the return type
    return 36;


Scope is defined by curly braces.

{ // this the beginning of a scope
    // the scope is about to end

Conditional StatementsEdit

If and only if A is equal to B assign C to D, otherwise, assign E to F.

if( A == B )
    D = C;
    // more code can be added here.  It is used if and only if A is equal to B
    F = E;
    // more code can be added here.  It is used if and only if A is not equal to B


if( A == B ) 
    D = C; //more lines of code are not permitted after this statement
    F = E;

Alternatively, a switch statement can be used for multiple choice operations. This sample converts a number input to text.

switch( number_value )
    case 37:
        text = "thirty-seven";
        break; // this line prevents the program from writing over this value with the
               //   following code
    case 23:
        text = "twenty-three";
    default: // this is used if none of the previous cases contain the value
        text = "unknown number";

Looping StatementsEdit

This code counts from 0 to 9, adding up the contents of the array.

int i = 0;
for( int index = 0; index < 10; index = index + 1 )
    i = array[index];

This code repeats until the number 4 is found. If this runs off of the end of the array, there could be a problem.

int index = 0;
while( 4 != array[index] )
    index = index + 1;

This code increments the counter before the check is made, so that it starts with element 1.

int index = 0;
    index = index + 1;
while( 4 != array[index] );

Output StatementsEdit

System.out.println( "Hello World!" );


Containers inherit from the Collection class. See the java.util package for specific containers including List, LinkedList, Queue, Stack, Dictionary and HashMap.


The Collection class has algorithms like sort.

Garbage collectionEdit

Garbage collection is automatic.

Physical StructureEdit

Code is generally kept in files with a .java extension. It is compiled into Java byte code into files with .class extensions.


  • Classes in the Java packages are capitalized, methods are not.
  • Everything is a pointer. Use a clone method to avoid operating on the original element of a Collection.
  • Arrays start with index 0.
  • Don't confuse these two:
=  // assignment
== // comparison, is equal to

Often using the one you don't want will compile, and will produce results you did not expect.

Web ReferencesEdit

Books and ArticlesEdit

paper references here