Eclipse shortcuts

https://blog.codecentric.de/en/2012/08/my-top-10-shortcuts-for-eclipse-on-mac-os-x-and-windows-and-how-you-survive-the-change-from-windows-to-mac/

op Description Shortcut Mac Shortcut Windows/Linux
1 Auto complete CTRL – SPACE CTRL – SPACE
2 Open / Search for resources, e.g. files CMD – SHIFT-R CTRL – SHIFT-R
3 Open / Search for Types CMD – SHIFT – T CTRL – SHIFT – T
4 Open class outline view CMD – O CTRL – O
5 Quickfix – result depending on cursor position CMD – 1 CTRL – 1
6 Search for references in the workspace CMD-SHIFT-G CTRL-SHIFT-G
7 Show type hierarchy CMD-T CTRL-T
8 Maximize Java editor CMD-M CTRL-M
9 Delete line CMD – D – R CTRL – D – R
10 Move line/block ALT – ↑ or ↓ ALT – ↑ or ↓

 

interface cannot be instantiation

1)
public interface Handler{
public void Hello();

2)
import Handler;
public class OtherParser{
Handler handler;
……
}

2) just uses a declaration of the interface, which is different from instiation

接口可以看成是高度抽象的抽象类,它描述的事物们所共有的方法(方法签名),也就是规定除了该接口的方法的调用参数与规则,仅仅而已,它的使用必须依赖于实现类。
例如:
public class MyHandler implements Handler{
public void Hellp(){
System.out.println(“my Handler implements”);
}
}
而在对接口的引用时,采用的是实例化实现该接口的类
Handler handler = new MyHander();

 

In the case below, Animal is an interface. it uses an anonymous class which is actually a class; that is why it can be instantiated.

Animal animal = new Animal() {
    public void Eat(String name) {
        System.out.printf("Someone ate " + food_name);
    }
};

 

static variable can be changed

as long as it is not “final”

public class StaticDemo {
static String name;

public static void staticVariable() {
name = name + ” ” + “Singh”;
System.out.println(“Value of static variable after method calling : ”
+ name);
}

public static void main(String[] args) {
System.out.println(“Initial value of static variable : ”
+ StaticDemo.name);
StaticDemo.name = “Bharat”;
System.out.println(“Value of static variable after initialization : ”
+ StaticDemo.name);
StaticDemo.staticVariable();
}

}

output:

Initial value of static variable : null
Value of static variable after initialization : Bharat
Value of static variable after method calling : Bharat Singh

reference in java and pointer in C

http://programmers.stackexchange.com/questions/141834/how-is-a-java-reference-different-from-a-c-pointer

References might be implemented by storing the address. Usually Java references will be implemented as pointers, but that’s not required by the specification. They may be using an additional layer of indirection to enable easier garbage collection. But in the end it will (almost always) boil down to (C-style) pointers being involved in the implementation of (Java-style) references.

You can’t do pointer arithmetic with references. The most important difference between a pointer in C and a reference in Java is that you can’t actually get to (and manipulate) the underlying value of a reference in Java. In other words: you can’t do pointer arithmetic.

In C you can add something to a pointer (i.e. the address) or substract something to point to things that are “nearby” or point to places that are at any place.

In Java, a reference points to one thing and that thing only. You can make a variable hold a different reference, but you can’t just ask it to point to “the thing after the original thing”.

References are strongly typed. Another difference is that the type of a reference is much more strictly controlled in Java than the type of a pointer is in C. In C you can have an int* and cast it to a char* and just re-interpret the memory at that location. That re-interpretation doesn’t work in Java: you can only interpret the object at the other end of the reference as something that it already is (i.e. you can cast a Object reference to String reference only if the object pointed to is actually a String).

Those differences make C pointers more powerful, but also more dangerous. Both of those possibilities (pointer arithmetic and re-interpreting the values being pointed to) add flexibility to C and are the source of some of the power of the language. But they are also big sources of problems, because if used incorrectly they can easily break assumptions that your code is built around. And it’s pretty easy to use them incorrectly.

java command line option

http://publib.boulder.ibm.com/infocenter/javasdk/v6r0/index.jsp?topic=%2Fcom.ibm.java.doc.diagnostics.60%2Fdiag%2Fappendixes%2Fcmdline%2Fcommands_jvm.html

-cp, -classpath <directories and compressed or .jar files separated by : (; on Windows)>
Sets the search path for application classes and resources. If -classpath and -cp are not used, and the CLASSPATH environment variable is not set, the user classpath is, by default, the current directory (.).
-help, -?
Prints a usage message.