throw

    0熱度

    3回答

    我很困惑,爲什麼當我將元素推入ArrayList時,我得到一個異常......這肯定是我的Push()方法的一個問題,任何人都可以找到問題嗎?我在if語句中嘗試了大括號,但沒有運氣,甚至可能是empty()方法的問題? 這裏是異常消息: Exception in thread "main" java.util.EmptyStackException at ArrayListStack.p

    3熱度

    1回答

    我怎麼能正確地拋出?它是有線的,對於相同的功能,既拋和not.throw通過測試 代碼也可在的jsfiddle,https://jsfiddle.net/8t5bf261/ class Person { constructor(age) { if (Object.prototype.toString.call(age) !== '[object Number]') th

    1熱度

    1回答

    當我點擊W,A,S或D我的元素應該朝某個方向走。 我用switch case語句處理它。 但是,如果用戶點擊其他密鑰怎麼辦?我將無法獲得新的職位。 我可以在默認情況下拋出一些異常,然後在try {...} catch {...}之後執行嗎? 下面是我的代碼: private boolean checkPos(String c) { int newPosX, newPosY;

    1熱度

    1回答

    我看到很多人寫的一樣: try { //something } catch (IOException e){ throw new SystemException("IO Error", e); } 我"Cannot instantiate the type SystemException"錯誤,似乎是SystemException的一個抽象類,我該怎麼能夠把它扔?

    1熱度

    3回答

    是否有可能從函數中拋出一個Lua錯誤,由調用函數的腳本來處理? 例如下面將拋出一個錯誤,在指定的評論 local function aSimpleFunction(...) string.format(...) -- Error is indicated to be here end aSimpleFunction("An example function: %i",nil)

    1熱度

    1回答

    我獲得以下誤差的一個值: Throwing method cannot be a member of an @objc protocol because it returns a value of type 'Bool'; return 'Void' or a type that bridges to an Objective-C class 當定義夫特協議,還需要橋接到目標C : @objc

    0熱度

    2回答

    我試圖用ifstream和所有try和catch方法打開一個文件。我想測試閱讀功能。而Im試圖讀取更多的文件長度即時獲取異常。但是,錯誤按摩: Error:basic_ios::clear: Success 我的代碼: void OpenFile(char* raw_slice) throw(std::ios_base::failure, std::string) { ifstr

    0熱度

    1回答

    我想有一個函數驗證對象。 如果出現錯誤結果,我想知道爲什麼我的對象無效。 這是一個樣的算法: public bool ValidObject(MyObjectClass obj) { if(obj==null) { throw Exception("obj cannot be null"); return false; } if(

    5熱度

    2回答

    我正在使用大量的異步網絡請求(順便說一句iOS中的任何網絡請求需要異步),我正在找到方法來更好地處理來自不支持throws的Apple dataTaskWithRequest的錯誤。 我有這樣的代碼是: func sendRequest(someData: MyCustomClass?, completion: (response: NSData?) ->()) { let reques

    1熱度

    1回答

    在我的actionPerformed方法中,我調用「copy()」克隆對象,但編譯器給我這個錯誤:「java.awt.event.ActionListener;重寫方法不會拋出java.lang.CloneNotSupportedException 「, 我能做什麼? public void actionPerformed(ActionEvent e){ if (e.getSource