Vincec's Dimension

Java Sytax & Structure Review

Word count: 3,890 / Reading time: 24 min
2019/05/27 Share

Array

  • int[] arr = new int[2]
  • int[] arr = {1, 2, 3}

Arrays API

ref

  • Search
  • Comparsion
  • Fill
  • Copy, Arrays.copyOf()
  • Sort
  • Arrays.binarySearch()
  • Arrays.euqals()
1
2
3
int size = 10;
int[] arr = new String[size];
Arrays.fill(arr, "-1");

Muti-dementions

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
String[][][] arr = {{{"000"}, {"100"}, {"200"}, {"300"}}, 
{{"010"}, {"110"}, {"210"}, {"310"}},
{{"020"}, {"120"}, {"220"}, {"320"}}};
//[down3][Across4][groups1]

/*
String[][][] arr = {
{
{"000"}, //arr[0][0][0]
{"100"},
{"200"},
{"300"}
},
{
{"010"},
{"110"},
{"210"}, //arr[1][2][0]
{"310"}
},
{
{"020"},
{"120"}, //arr[2][1][0]
{"220"},
{"320"}
}
};
*/

int[][] rent = {{400, 550, 700},
{500, 344, 342}};
//rest[row][col]

Collection Interface*

Collections*

ArrayList vs. LinkedList vs. Vector

  • ArrayList is implemented as a resizable array. As more elements are added to ArrayList, its size is increased dynamically. It’s elements can be accessed directly by using the get and set methods, since ArrayList is essentially an array. (Not thread safe)
  • LinkedList is implemented as a double linked list. Its performance on add and remove is better than Arraylist, but worse on get and set methods. (Not thread safe)
  • Vector(outdated) is similar with ArrayList, but it is synchronized. (Thread safe, but can use java.util.concurrent.CopyOnWriteArrayList to replace)

_Ref: Vector & Stack_

Stack class is the child class of Vector.

  • It follows LIFO (Last in first out) mechanism.
  • It is the stack implementation in java

Additional methods defined by Stack

  1. Object push(Object item), Pushes the element into Stack and returns the same element
  2. Object pop(), Removes the element from Stack and returns the element
  3. Object peek(), Returns the top element from Stack.
  4. Object empty(), Returns true when the Stack is empty.
  5. int search(Object o), Returns the offset value from the stack if the element is found, otherwise it returns -1.

List

Vector

ref

  • All the methods of Vector is synchronized. But, the methods of ArrayList is unsynchronized, thread-safe operation need Vector, but cost time
  • When you use Vector or ArrayList, always initialize to the largest capacity that the java program will need. Since incrementing the size is a costlier operation.

Method & prop

ref

  • add(E element), add(int index, E element), addAll(int index, Collection<> c, addElement(E element)
  • capacity()
  • clear()
  • clone()
  • contains(), containsAll(Collection<> c)
  • copyInto(Object[] array)
  • elementAt(int index)
  • equals(Object o)
  • get(int index), set(int index, E element)
  • indexOf(Object o)
  • remove(int index), remove(Object o) and removeAll(Collection<?> c)
  • removeElement(Object obj), removeElementAt(int index)
  • size()
  • toArray()

ArrayList

  • by resizable array
  • can only hold objects
  • can increase and decrease the size, array can not
  • Use .get(), and .set()
  • Use .add()
  • sort, public void sort(Comparator<? super E> c), need extened

LinkedList

  • by double linked list
  • sort by Collection.sort() method.

Stack(Vector), Queues, PriorityQueues

Stack(Vector)

First In Last Out

  • push
  • pop
  • peek: the top of the stack

Queue

First In First Out

  • front, out from frist
  • rear, add from rear
  • insert
  • remove
  • peek

Deque

Deque interface in Java with Example

The java.util.Deque interface is a subtype of the java.util.Queue interface. The Deque is related to the double-ended queue that supports addition or removal of elements from either end of the data structure, it can be used as a queue (first-in-first-out/FIFO) or as a stack (last-in-first-out/LIFO). These are faster than Stack and LinkedList.

Few important features of Deque are:

  • It provides the support of resizable array and helps in restriction-free capacity, so to grow the array according to the usage.
  • Array deques prohibit the use of Null elements and do not accept any such elements.
  • Any concurrent access by multiple threads is not supported.
  • In the absence of external synchronization, Deque is not thread-safe.
Methods

check Deque
Interface Deque

  • iterator(): Return an iterator for this deque., descendingIterator()
Queue Interface, FIFO (First-In-First-Out), ADD, REMOVE
  • add(element) = addLast(element), addFirst(element), to tail
  • offer(element) = offerLast(element), offerFirst(element) to tail
  • remove() = removeFirst(), removeLast(), to head
  • poll() = pollFirst(), pollLast(), Retrieves and removes the head (first element) of this list, handling for expection with null example
  • element() = getFirst()
  • peek() = peekFirst(), peekLast(), head
Stack Interface, LIFO (Last-In-First-Out), PUSH, POP (reverse stack)
  • push(element), Adds an element to the head.
  • pop(element), Removes an element from the head and returns it.
  • peek() = peekFirst(), peekLast(), Retrieves, but does not remove, the head (first element) of the queue represented by this deque, returns null if this deque is empty.

Priority Queue

insert queue with proper order

1
2
3
4
5
6
7
8
/*
PriorityInsert 10
PriorityInsert 19
PriorityInsert 15
PriorityInsert 11

queue: 19 15 11 10
*/

Map

  • Map
  • HashMap vs HashSet vs Hashtable – HashMap, HashTable, TreeMap and LinkedHashMap with Examples

    Maps are described by the Map interface. Map interface has no parent interface and is declared as
    Map<K,V>

    • K is the key’s type
    • V is the value’s type
      Unlike List, Set, and Queue, Map does not extend Collection. It is possible to get a Collection instance by calling Map’s keySet(), values(), and entrySet() methods, which respectively return a Set of keys, a Collection of values, and a Set of key/value pair entries.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public static void main(String[] args) {
Map<String, Color> colorMap = new HashMap<String, Color>();
colorMap.put("red", Color.RED);
colorMap.put("blue", Color.BLUE);
colorMap.put("green", Color.GREEN);
colorMap.put("RED", Color.RED);
for (String colorKey : colorMap.keySet()){
System.out.println(colorKey);
}

Collection<Color> colorValues = colorMap.values();
for (Iterator<Color> it = colorValues.iterator(); it.hasNext();){
System.out.println(it.next());
}
}

4 commonly used implementations of Map in Java SE - HashMap, TreeMap, Hashtable and LinkedHashMap

HashMap, TreeMap, LinkedHashMap, (HashTable)

HashMap vs TreeMap

  • Both TreeMap and HashMap don’t support duplicate keys.
  • Both Map implementations aren’t synchronized
  • The Iterator throws a ConcurrentModificationException if the Map gets modified in any way and at any time once the iterator has been created.

  • Using put();

HashMap(Most Use)

  • Implemented as a hash table
  • No ordering on keys or values
  • At most one null key and many null values.
  • O(1) with add(), remove(), and contains();
  • Waste memory compared with TreeMap
  • HashMap can be tuned using the initialCapacity and loadFactor, which isn’t possible for the TreeMap

  • Used in thread-safe, otherwise use synchronized Hashtable, which not allow null.

TreeMap

  • Implemented based on red-black tree structure
  • It is naturally ordered by the key
  • No null is allowed but ok for null value
  • O(log(n)) for most operations like add(), remove() and contains()
  • Save memory compared with HashMap

Others

  • LinkedHashMap , LinkedHashMap is a subclass of HashMap, preserves the insertion order
  • Hashtable is synchronized, in contrast to HashMap.
  • Hashtable is simply an implementation of the Dictionary ADT, Not use Dictionary because obsolete.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//HashMap with self object class
class Dog {
String color;

Dog(String c) {
color = c;
}

public boolean equals(Object o) {
return ((Dog) o).color.equals(this.color);
//If the key of a HashMap is a self-defined object, then the equals() and hashCode() contract need to be followed.
//the hashCode() and equals() methods implemented in the Object class prevent identical
//hashCode() method gives distinct integers
//equals() method only returns true with two references reference
}

public int hashCode() {
return color.length();
}

public String toString(){
return color + " dog";
}
}


public static void main(String[] args) {
HashMap<Dog, Integer> hashMap = new HashMap<Dog, Integer>();
Dog d1 = new Dog("red");
Dog d2 = new Dog("black");
Dog d3 = new Dog("white");
Dog d4 = new Dog("white");

hashMap.put(d1, 10);
hashMap.put(d2, 15);
hashMap.put(d3, 5);
hashMap.put(d4, 20);

//print size
System.out.println(hashMap.size());

//loop HashMap
for (Entry<Dog, Integer> entry : hashMap.entrySet()) {
System.out.println(entry.getKey().toString() + " - " + entry.getValue());
}
}

//output
3
red dog - 10
white dog - 20 //equal() will check if the key is same for self-define class
black dog - 15

//using LinkedHashMap with instering order
red dog - 10
black dog - 15
white dog - 20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//TreeMap with self-class
class Dog implements Comparable<Dog>{ //need to comapre for treemap for sorting
String color;

Dog(String c) {
color = c;
}

public String toString(){
return color + " dog";
}

@Override
public int compareTo(Dog o) {
//need to override the key compare for sorting, uses compareTo() method to compare keys
return o.color.compareTo( this.color );
}
}

public class TestTreeMap {
public static void main(String[] args) {

TreeMap<Dog, Integer> treeMap = new TreeMap<Dog, Integer>();

treeMap.put(new Dog("red"), 10);
treeMap.put(new Dog("black"), 15);
treeMap.put(new Dog("white"), 5);
treeMap.put(new Dog("white"), 20);

for (Entry<Dog, Integer> entry : treeMap.entrySet()) {
System.out.println(entry.getKey() + " - " + entry.getValue());
}
}
}

//output
white dog - 20
red dog - 10
black dog - 15
white dog - 5, sort by order or override the same key

Set

HashSet

  • HashSet implements Set interface.
  • using Add();
  • HashSet is slower then HashMap
  • No duplicate is allowed, make sure have equals() and hashCode()
  • HashMap internally uses hashing to store or add objects, HashSet internally uses HashMap object to store or add the objects.

  • HashSet requires only one object add(Object o) .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public static void main(String[] args) 
{

HashSet<String> hs = new HashSet<String>();
// Adding elements to the HashSet
hs.add("geeks");
hs.add("practice");
hs.add("contribute");

System.out.println("Before adding duplicate values \n\n" + hs);

// Addition of duplicate elements
hs.add("geeks");
hs.add("practice");

System.out.println("\nAfter adding duplicate values \n\n" + hs);

// Addition of null values
hs.add(null);
hs.add(null);

// Displaying HashSet elements
System.out.println("\nAfter adding null values \n\n" + hs);
}

Enum type

Comparing Enum Types using “==” Operator
EnumSet and EnumMap, efficient and compact

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
enum Level {
LOW,
MEDIUM,
HIGH
}

//access
Level myVar = Level.MEDIUM;

//switch
Level myVar = Level.MEDIUM;
switch(myVar) {
case LOW:
System.out.println("Low level");
break;
case MEDIUM:
System.out.println("Medium level");
break;
case HIGH:
System.out.println("High level");
break;
}

//for loop
for (Level myVar : Level.values()) {
System.out.println(myVar);
}

Loops

Loops in Java

While (Entry control loop)

1
2
3
4
while (boolean condition)
{
loop statements...
}

For (Entry control loop)

1
2
3
4
for (initialization condition; testing condition;increment/decrement)
{
statement(s)
}

Enhanced For loop after java 5

For-each loop in Java

  • not appropriate when you want to modify the array
  • do not keep track of index
  • only iterates forward over the array in single steps
  • cannot process two decision making statements
    1
    2
    3
    4
    for (T element:Collection obj/array)
    {
    statement(s)
    }

do while (Exit control loop)

1
2
3
4
5
do
{
statements..
}
while (condition);

Java Access Modifiers

Java Access Modifiers
Java access modifiers – public, protected, private and default

Controlling Access

public > protected > package-private (or default) > private

  • public – accessible everywhere
  • protected – accessible in the same package and in sub-classes
  • default – accessible only in the same package
  • private – accessible only in the same class

Other Modifiers

Modifiers, Access Control, and Class Design

  • The static modifier for creating class methods and variables
  • The abstract modifier, for creating abstract classes and methods
  • The final modifier, for finalizing the implementations of classes, methods, and variables
  • The synchronized and volatile modifiers, which are used for threads and which you’ll learn more about on Day 18, “Multithreading”
  • The native modifier, which is used for creating native methods, which you’ll learn about on Day 21, “Under the Hood”

Usual order: ACCESS static abstract synchronized volatile final native

static

While static has a specific meaning for where a method or variable is stored in a program’s runtime memory in those languages, static simply means that it’s stored in the class in Java.

Java: when to use static methods

Obj.someMethod / instead of calling new Util().method(arg), call Util.method(arg), or method(arg) with static imports.

  • If you are writing utility classes and they are not supposed to be changed.
  • If the method is not using any instance variable.
  • If any operation is not dependent on instance creation.
  • If there is some code that can easily be shared by all the instance methods, extract that code into a static method.
  • If you are sure that the definition of the method will never be changed or overridden. As static methods can not be overridden.

A static method is one type of method which doesn’t need any object to be initialized for it to be called. Have you noticed static is used in the main function in Java? Program execution begins from there without an object being created.

Consider the following example:

1
2
3
4
5
6
7
8
9
10
11
12
class Languages 
{
public static void main(String[] args)
{
display();
}

static void display()
{
System.out.println("Java is my favorite programming language.");
}
}


Use instance variables when : Every variable has a different value for different object. E.g. name of student, roll number etc..

Use static variables when : The value of the variable is independent of the objects (not unique for each object). E.g. number of students.

final

  • (final classes): To prevent others from subclassing your class. If your class has all the capabilities it needs, and no one else should be able to extend its capabilities, then that class should be final.
  • (final classes): For better efficiency. With final classes you can rely on instances of only that one class (and no subclasses) being around in the system, and optimize for those instances.
  • (final method): The only reason to declare a method final is efficiency, like accessor methods.(Private methods are effectively final, as are all methods declared in a final class.)

abstract

  • Abstract classes are classes whose sole purpose is to provide common information for subclasses. Abstract classes can have no instances.
  • Abstract methods are methods with signatures, but no implementation. Subclasses of the class which contains that abstract method must provide its actual implementation.

OOP

ref: lynda

  • Data instance(keep private), constructor, method(get(accessor) and set(mutator) method), override(need implement comparable)
  • Encapsulation 封装
    • hide instance data definition
    • Protects the integrity instance data
    • hides the method implementations
    • prevents outside access with protective barrier
  • Avoid null references
  • Inheritance(is-A) 继承, It is the mechanism in java by which one class is allow to inherit the features(fields and methods) of another class.
    • Extends, for inheritance
    • Implements, for interface
    • abstract class
  • Polymorphism 多态性

Inheritance

ref

  • Super Class
  • Sub Class
  • Reusability
1
2
3
4
class derived-class extends base-class  
{
//methods and fields
}
  • Single Inheritance
  • Multilevel Inheritance, class one, class two extends one, class three extends two
  • Hierarchical Inheritance(one to more), class one, class two extends one, class three extends one
  • Multiple Inheritance(Through Interfaces)(more to one), interface one, interface two, interface three extends one,two, class child implements three
  • Hybrid Inheritance(Through Interfaces)

Important facts in Java

  • Default superclass
  • Superclass can only be one
  • Inheriting Constructors
  • Private member inheritance

Abstract class

ref

An abstract class is a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated(no Shape shape = new Shape()), but they can be subclassed. An abstract class may have static fields and static methods.

May or may not include abstract methods

Something more than an interface

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
abstract class MotorVehicle
{
String name;
int fuel;

MotorVehicle(){
name = "MotorVehicle"
fuel = 0;
}

MotorVehicle(String name, int f){
this.name = name;
}

MotorVehicle(String name){
this.name = name;
fuel = f;
}

int getFuel()
{
return this.fuel;
}

abstract void run();
}

class Car extends MotorVehicle
{
Car(){
super("Car"); //using the super constructor
}

Car(String name){ //customized constructor
super(name);
}

void run() //must need to implement run()
{
print("Wrroooooooom");
}
}

Interface

ref
interfaces are having only abstract methods, has no code only pattern, class implement interface must including all method in interface. They are empty body.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// I say all motor vehicles should look like this:
interface MotorVehicle
{
void run();
int getFuel();
}

// My team mate complies and writes vehicle looking that way
class Car implements MotorVehicle
{

int fuel;
void run() //need implement
{
print("Wrroooooooom");
}

int getFuel() //need implement
{
return this.fuel;
}
}

Methods and Declarations in Interface

  • abstract method (no need to sign, no braces)
  • default method, default public void newDefaultMethod(){....}, to modify interface instead of breaking all the codes
  • static method, can not be overriden in implementation class
  • Constant Declarations, public static final int NORTH = 0;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
interface NewInterface { 

// static method
static void hello()
{
System.out.println("Hello, New Static Method Here");
}

// default method
default void newDefaultMethod(){....}

// Public and abstract method of Interface
void overrideMethod(String str);
}

Polymorphism

Polymorphism is that it allows you to have the same name for a method, but it acts differently based on the class that has that method defined.

  • Used when classes are inherited from a superclass
  • Methods of the subclass may need to behave differently
  • Same method name, but different implementation

UML Unified Modeling Language

Design Pattern

Singleton Design Pattern

restricts the instantiation of a class to one “single” instance.

using instance

1
2
3
4
//var policy = new Policy();
//var insureName = policy.getInsuredName();

var insureName = Policy.Instance.getInsuredName();

Policy class change

readonly on lock

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// using lock
private static readonly object _lock = new object();

private static Policy _instance;
public static Policy Instance{
get {
lock(_lock){ // lock for multi-theads
if(_instance == null){
_instance = new Policy();
}
return _instance;
}

}
}
//ctor shortcut

public Policy()
{

}

readonly on Instance(shorter and cleaner)

1
2
3
4
5
6
7
8
9
10
11
private static readonly Policy _instance = new Policy();

public static Policy Instance{
get{
return _instance;
}
}

public Policy(){

}

Decorator Pattern(Wrapper Pattern)

ref: Decorator Pattern, 装饰模式ref1, 装饰模式ref2, 装饰模式ref3, Decorator 模式

  1. Decorator used to add new functionality to an existing object without changing its structure.
  2. 修饰模式, or 装饰模式
    • 抽象组件(Component) :定义装饰方法的规范
    • 被装饰者(ConcreteComponent) :Component的具体实现,也就是我们要装饰的具体对象。
    • 装饰者组件(Decorator) :持有组件(Component)对象的实例引用,该类的职责就是为了装饰具体组件对象,定义的规范。
    • 具体装饰(ConcreteDecorator) :负责给构件对象装饰附加的功能。

Sample Code

Vehicle, Component Interface.

1
2
3
4
5
6
public interface Vehicle
{
string Make { get; }
string Model { get; }
double Price { get; }
}

HondaCity : Vehicle, ConcreteComponent class.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public class HondaCity : Vehicle
{
public string Make
{
get { return "HondaCity"; }
}

public string Model
{
get { return "CNG"; }
}

public double Price
{
get { return 1000000; }
}
}

VehicleDecorator: Vehicle, Decorator Class.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public abstract class VehicleDecorator : Vehicle
{
private Vehicle _vehicle;

public VehicleDecorator(Vehicle vehicle)
{
_vehicle = vehicle;
}

public string Make
{
get { return _vehicle.Make; }
}

public string Model
{
get { return _vehicle.Model; }
}

public double Price
{
get { return _vehicle.Price; }
}
}

SpecialOffer : VehicleDecorator, ConcreteDecorator class.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public class SpecialOffer : VehicleDecorator
{
public SpecialOffer(Vehicle vehicle) : base(vehicle) { }

public int DiscountPercentage { get; set; }
public string Offer { get; set; }

public double Price
{
get
{
double price = base.Price;
int percentage = 100 - DiscountPercentage;
return Math.Round((price * percentage) / 100, 2);
}
}
}

Program

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Program
{
static void Main(string[] args)
{
// Basic vehicle
HondaCity car = new HondaCity();

Console.WriteLine("Honda City base price are : {0}", car.Price);

// Special offer
SpecialOffer offer = new SpecialOffer(car);
offer.DiscountPercentage = 25;
offer.Offer = "25 % discount";

Console.WriteLine("{1} @ Diwali Special Offer and price are : {0} ", offer.Price, offer.Offer);

Console.ReadKey();
}
}

Iterator Pattern

Others

Random

Math.random(), [0.0,1.0)

Parse

1
Integer.parseInt("-1");

Compareable Interface

For override compareTo()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public class Address implements Comparable{
//.....

@Override
public int compareTo(Object a){
Address addr = (Address)a;
int zip1 = Integer.parseInt(this.zipcode);
int zip2 = Integer.parseInt(addr.zipcode);
if(zip1 < zip2){
return -1;
}else if(zip1 > zip2){
return 1;
}else{
return 0;
}
}
}

异或 Exclusive or

XOR gate
136.single-number.md

  • 任何数和本身异或则为0
  • 任何数和 0 异或是本身
1
2
3
4
5
6
7
8
9
10
//https://leetcode.com/problems/single-number/submissions/
class Solution {
public int singleNumber(int[] nums) {
int r = 0;
for(int i = 0; i < nums.length; i++){
r = r ^ nums[i];
}
return r;
}
}

Bit Operator

Check post of [Bit Operate with Unsigned Integer]

Reference

Author: VINCEC

Permalink: https://vince-amazing/blog/2019/05/27/structure-review/

Date: May 27th 2019, 1:14:00

Copyright license: The article usingCC licensing 4.0

CATALOG
  1. 1. Array
    1. 1.1. Arrays API
    2. 1.2. Muti-dementions
  2. 2. Collection Interface*
    1. 2.1. List
      1. 2.1.1. Vector
        1. 2.1.1.1. Method & prop
      2. 2.1.2. ArrayList
      3. 2.1.3. LinkedList
    2. 2.2. Stack(Vector), Queues, PriorityQueues
      1. 2.2.1. Stack(Vector)
      2. 2.2.2. Queue
        1. 2.2.2.1. Deque
          1. 2.2.2.1.1. Methods
            1. 2.2.2.1.1.1. Queue Interface, FIFO (First-In-First-Out), ADD, REMOVE
            2. 2.2.2.1.1.2. Stack Interface, LIFO (Last-In-First-Out), PUSH, POP (reverse stack)
      3. 2.2.3. Priority Queue
  3. 3. Map
    1. 3.1. HashMap, TreeMap, LinkedHashMap, (HashTable)
    2. 3.2. HashMap vs TreeMap
      1. 3.2.1. HashMap(Most Use)
      2. 3.2.2. TreeMap
      3. 3.2.3. Others
  4. 4. Set
    1. 4.1. HashSet
  5. 5. Enum type
  6. 6. Loops
    1. 6.1. While (Entry control loop)
    2. 6.2. For (Entry control loop)
      1. 6.2.1. Enhanced For loop after java 5
    3. 6.3. do while (Exit control loop)
  7. 7. Java Access Modifiers
    1. 7.1. Controlling Access
    2. 7.2. Other Modifiers
      1. 7.2.1. static
    3. 7.3. final
    4. 7.4. abstract
  8. 8. OOP
    1. 8.0.1. Inheritance
      1. 8.0.1.1. Important facts in Java
    2. 8.0.2. Abstract class
    3. 8.0.3. Interface
      1. 8.0.3.1. Methods and Declarations in Interface
    4. 8.0.4. Polymorphism
  • 9. UML Unified Modeling Language
  • 10. Design Pattern
    1. 10.1. Singleton Design Pattern
      1. 10.1.1. using instance
      2. 10.1.2. Policy class change
    2. 10.2. Decorator Pattern(Wrapper Pattern)
      1. 10.2.1. Sample Code
    3. 10.3. Iterator Pattern
  • 11. Others
    1. 11.1. Random
    2. 11.2. Parse
    3. 11.3. Compareable Interface
    4. 11.4. 异或 Exclusive or
    5. 11.5. Bit Operator
  • 12. Reference