Java - Questions

How to Say These Characters

() open/close parenthesis, round brackets
[] square brackets
{} brace
/ slash
, comma
; semicolon
. period
- hyphen
-- dash dash

Static

Overriding & Overloading

e.g. Override toString() to get class’s info

class Test {
	...
	public String toString(){
		return "This is Test class";
	}
}
...
{
	Test test = new Test();
	System.out.print(test);
}

Local variables v.s. Instance variables

Abstract class vs Interface

HashMap Implementation

http://blog.csdn.net/vking_wang/article/details/14166593

Java代码编译执行流程

Java Pass-By-Value (Pass-By-Copy)

Senario 1: primitives

int x = 100; // x's value
addOne(x); // copy of x's value 100 is passed to the method
print(x); // result: 100

Senario 2:

Account a = new Account("1001"); // a is a reference to the Account Object 1001
Account b = a; // b is a copy of a, which also points to Account Object 1001
a == b; // true
a = new Account("1002"); // point a to a new Account Object 1002
b.getAccountNumber(); // result: 1001, b still points to Account Object 1001

Main Method in Java Web Project

Why don’t I see any main method in the Java web project?

Java Constant Pooling

We know that:

String a = "hello";
String b = "hello";
a == b // true

Because a and b point to the same String literal “hello”. But where are they actually stored?

When a new Sting is declared and being assigned a literal, like String c = "hello", it first goes the the Runtime Constant Pool - String Constants to check if there’s any existing value.

服务器集群session数据同步问题

Fork me on GitHub