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

141 lines
3.5 KiB
Markdown
Raw Blame History

<!-- GFM-TOC -->
* [????](#????)
* [ final](#-final)
* [????????](#????????)
* [???????](#???????)
* [????](#????)
* [Set](#set)
* [Queue](#queue)
* [Map](#map)
* [????](#????)
* [??](#??)
* [?¦Ï?????](#?¦Ï?????)
<!-- GFM-TOC -->
# ????
## final
**final ????**
??????????????????????????????????????????????????????????????????
????????????final ???????????????????final ????¨°?????????????????????????????????????????????
**final ????**
????????????????????
private ?????????????? final????????????§Ø?????????????§Ö???? private ????????????????????????????????????????????????
**final ??**
????????????§³?
## ????????
static ??????????????????????????????????????????????????¦²??????????????????????
```java
public static String staticField = "???????";
```
static ????? static ???????????????????????????¦²?????????????????????????????§Ö????
```java
static {
System.out.println("??????????");
}
```
??????????????????????????????????????????????
```java
public String field = "????";
```
```java
{
System.out.println("???????");
}
```
????????????§Ö???????§Ô????
```java
public InitialOrderTest()
{
System.out.println("??????");
}
```
?????§Ö??????????????????
1. ??????????????????ï‚
2. ??????????????????ï‚
3. ????????????ï‚
4. ????????????
5. ????????????ï‚
6. ????????????
## ???????
Java ??????????????????¦Ç???private??protected ??? public???????????????¦Ç???????????????
???????????§Ö???????????????????????????¦Ç??????????????????????¨®?????????????????¨®????????????????????????????????????????????§Ö??????????????????????????????????
protected ???????¦Ã???????????????§Ô????????????????????????????¦Ç?????????????ÈÉ???????§Þ???????
# ????
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/114c49a6-72e3-4264-ae07-c564127094ac.png)
??????????? 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???????????????????????
![](https://github.com/CyC2018/InterviewNotes/blob/master/pics/48f8f98e-8dfd-450d-8b5b-df4688f0d377.jpg)
# ?¦Ï?????
- Eckel B, ????? , ??? , ?? . Java ?????? [M]. ??§Ö????????? , 2002.
- [Java ????????? ](https://segmentfault.com/a/1190000004527951)