CS-Notes/notes/Java 基础语法.md
2018-02-22 22:54:49 +08:00

3.5 KiB
Raw Blame History

????

final

final ????

??????????????????????????????????????????????????????????????????

????????????final ???????????????????final ????¨°?????????????????????????????????????????????

final ????

????????????????????

private ?????????????? final????????????§Ø?????????????§Ö???? private ????????????????????????????????????????????????

final ??

????????????§³?

????????

static ??????????????????????????????????????????????????¦²??????????????????????

public static String staticField = "???????";

static ????? static ???????????????????????????¦²?????????????????????????????§Ö????

static {
    System.out.println("??????????");
}

??????????????????????????????????????????????

public String field = "????";
{
    System.out.println("???????");
}

????????????§Ö???????§Ô????

public InitialOrderTest()
{
    System.out.println("??????");
}

?????§Ö??????????????????

  1. ??????????????????ï‚
  2. ??????????????????ï‚
  3. ????????????ï‚
  4. ????????????
  5. ????????????ï‚
  6. ????????????

???????

Java ??????????????????¦Ç???private??protected ??? public???????????????¦Ç???????????????

???????????§Ö???????????????????????????¦Ç??????????????????????¨®?????????????????¨®????????????????????????????????????????????§Ö??????????????????????????????????

protected ???????¦Ã???????????????§Ô????????????????????????????¦Ç?????????????ÈÉ???????§Þ???????

????

??????????? Collection ?? Map ?????Collection ??????? List??Set ??? Queue??

Set

  • HashSet????? Hash ???????????????????????????

  • TreeSet?????????????????????????§¹????? HashSet??

  • LinkedListHashSet?????? HashSet ?????§¹?????????????????????????????????????????

Queue

???????????LinkedList ?? PriorityQueue?????? LinkedList ????????§³?

Map

  • HashMap????? Hash ???

  • LinkedHashMap???????????????????????????????????LRU?????

  • TreeMap?????????????

  • ConcurrentHashMap??????? Map?????<3F>p???????

????

?????????? Class ??????????????§Û???????????????????????????????????? .class ??????????????????? Class ????

????????? Class ?????????????????????????????? JVM ?§µ???????? Class.forName('com.mysql.jdbc.Driver.class') ????????????????????¡Â?????????? Class ????

???????????????????????????????????????????????????????????????????? .class ???????????????????

Class ?? java.lang.reflect ???????????????java.lang.reflect ???????? Field??Method ??? Constructor ????????? get() ?? set() ???????????? Field ???????????¦²???????? invoke() ?????????? Method ???????????????????? Constructor ??????????

IDE ??¡Â???????????????????????????????????????????¦±??????????????????§Ô???????????

??

Throwable ????????????¦Ê¦Ï???????????????????????Error ?? Exception?????? Error ??????????????????

Exception ????????????? ?? ??????????????????? try...catch... ???????§Õ??????????????§Ý?????????????????????????????? 0 ?????? Arithmetic Exception???????????????????????

?¦Ï?????

  • Eckel B, ????? , ??? , ?? . Java ?????? [M]. ??§Ö????????? , 2002.
  • Java ?????????