java reg expression escape

* is a reserved character in regexes, so you need to escape it using "//"
line.split("\\*"); // for '*' in java
'\\\\+'; // for '+' in python
Advertisements

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);
    }
};