2016-10-26

posted Oct 26, 2016, 6:21 AM by Samuel Konstantinovich   [ updated Oct 26, 2016, 6:38 AM ]
Do Now:
    On Paper: 
    1. Write a method that takes an array of int, and returns the sum of all of the elements.
    2. Now consider how you would write the method in such a way that you also know the startIndex, and endIndex. Now how would you modify your code to find the sum of all of the elements from startIndex to endIndex, not including the endIndex. 
    3. What should happen when startIndex == endIndex?
    4. Write the method:

public static partialSum(int[]ary, int start, int end){  
    ... 
}

CodingBat!!
Comments