當try,catch,finally中均有return語句時,會返回哪個?---finally中的return

1.當try,catch,finally中都有return語句時,不管try中的語句有無異常,均返回finally中的return。java

public static int getStr() {
        try {
            int str = 1/0;
            return str;
        } catch (Exception e) {
            return 2;
        } finally {
            return 3;
        }
    }
    public static void main(String[] args) {
        System.out.println(getStr());
    }


執行結果:

java.lang.ArithmeticException: / by zero
	at com.test.frame.fighting.application.getStr(application.java:14)
	at com.test.frame.fighting.application.main(application.java:25)
3

Process finished with exit code 0

-----------------------------------------當改爲try中無異常時---------------
  public static int getStr() {
        try {
            return 1;
        } catch (Exception e) {
            return 2;
        } finally {
            return 3;
        }
    }
    public static void main(String[] args) {
        System.out.println(getStr());
    }

運行結果:
3

Process finished with exit code 0

2.ajax中的4個字母分別是什麼?分別表明什麼意思?ajax

ajax:Asynchronous Javascript And xml 異步Javascript和xml.是一種動態建立網頁技術,是指在不從新加載整個網頁的狀況下,實現部分網頁數據的更新,與後臺服務器交換數據,並在頁面上顯示出來的技術。Ajax能夠使網頁異步更新服務器

3.xml全程是什麼?app

可擴展標記語言 異步

4. ==和equals的區別code

==表示兩個變量的值是否相等,即兩個變量所對應的內存中存儲的數據值是否相等。xml

equals是用於比較兩個獨立對象的內容是否相同,就比如去比較兩我的的長相是否相同,它比較的兩個對象是獨立的。對象

==比較兩我的是否到底是真正同一我的,equals通常用來比較兩我的在邏輯上是否相等(好比規定兩人成年以後身高相同就算兩人相同等等),ip

因此字符串的比較通常都有equals方法。內存

相關文章
相關標籤/搜索