標籤:public int findLast(int[] x, int y){ //Effects:If X==null thro NullPointerException //else return the index of the last element //in x that equals y. //If no such element exists, return -1 for(int i=x.length-1; i> 0;i--)
標籤:上課沒做出的原因:由於很長時間沒有做過編程,寫過代碼,對java的一些語言早已忘光,以後還得好好複習一下java.程式設計思想:用Math.random隨機產生100以內的整數,利用字元數組將定義加減乘除符號,而且要考慮兩個數相除時,分母不為0;然後輸出就行原始碼:public class Suiji { public static void main(String args[]) { int i,j,y,h,g,f; &
標籤:觀察兩段代碼並回答下列問題:(1) 發現錯誤碼;(2) 試著編寫測試案例,不執行fault部分;(3) 執行fault部分,但不出現error情況;(4) 出現error情況,但不發生failure。 代碼一:public int findLast (int[] x, int y) {//Effects: If x==null throwNullPointerException// else return the index of the last element// in x
標籤:第二次作業對於以下兩個程式1、找出fault2、如果可能的話,找出一個測試案例不執行fault3、如果可能的話,找出一個測試案例執行fault,但是不產生error4、如果可能的話,找出一個測試案例產生error,但是不會導致failurepublic intfindLast(int[] x, inty) {//Effects: If x==null throw NullPointerException// else return the index of the last
標籤:public int findLast (int[] x, int y) { //Effects: If x==null throw NullPointerException // else return the index of the last element // in x that equals y. // If no such element exists, return -1 for (int i=x.length-1; i > 0; i--) { if (x[i] ==