You are viewing a single comment's thread. Return to all comments →
class Difference { private int[] elements; public int maximumDifference;
// Add your code here public Difference(int[] a){ this.elements =a; } public int computeDifference() { for(int i=0; i<elements.length; i++) { for(int j=i+1; j<(elements.length); j++) { int differnece = Math.abs( elements[i] - elements[j] ); if(differnece > maximumDifference) { maximumDifference = differnece; } }
} return maximumDifference; }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 14: Scope
You are viewing a single comment's thread. Return to all comments →
class Difference { private int[] elements; public int maximumDifference;
} return maximumDifference; }