finding the start and end index for a max sub array
<pre><code> public static void main(String[] args) {


        int arr[]= {0,-1,2,-3,5,9,-5,10};



        int max_ending_here=0;
        int max_so_far=0;
        int start =0;
        int end=0;

        for(int i=0;i&lt; arr.length;i++)
        {
            max_ending_here=max_ending_here+arr[i];
            if(max_ending_here&lt;0)
            {
                max_ending_here=0;
            }

            if(max_so_far&lt;max_ending_here){

                max_so_far=max_ending_here;


            }

        }
        System.out.println(max_so_far);



    }

}
</code></pre>

<p>this program generates the max sum of sub array ..in this case its 19,using {5,9,-5,10}..
now i have to find the start and end index of this sub array ..how do i do that ??</p>
