代碼: System.out.println("Please choose an option");
Choice=user_input.next().charAt(0);
//entering 1 as char thats when it displayes "Do you want to open" then gives me index out of bonds error
if (
我有一些具有相同超類型的類。因此所有這些類都必須覆蓋相同的方法。現在我可以調用一個方法並將它提交給一個普通超類型的對象。但是對每個提交類型做出反應並不總是有用,因此引發異常。首先,我試圖解決這個問題是這樣的: def operation(s: SuperType) = s match {
case t: SubType1 => ...
case t: SubType2 => .