# To figure out what method does

• 03-14-2012, 10:06 PM
farahm
To figure out what method does
hello
i am currently trying to figure out what a certain method does so as to proceed to annotate it, providing a post condition and loop invariant.
what i figured out:
on a positive and negative array and all positive x becomes positive upon the first time the minimum is encountered but when the array is all negative x and y are the sum of the elements
anyone see another approach to analyzing to this method?
```public class funA{     public static void functionOfA( int a[]){         int MAXINT= Integer.MAX_VALUE;         int x= MAXINT;         int y= MAXINT;         int i= 0;         int n= a.length;         while( i!= n){              if( y== MAXINT){                 //y= MAXINT                 y= a[i];                 //y= a[i]                 x= min( x, y);                 //x= min(x,y)                 System.out.println("x: " +x + " y: "+ y);                 i= i+1;                 //y= a[i-1];             } else{                 y= min( y+ a[i], a[i]);                 // y= min( y+ a[i], a[i]);                 x= min( x, y);                 //x= min( x, y);                 System.out.println("x: " +x + " y: "+ y);                 i= i+1;                 // y= min( y+ a[i-1], a[i-1]);             }          }         System.out.println( x+ " "+ y);     }     public static int min( int x, int y){         if( x< y){             return x;         }         else{             return y;         }     }     public static void main ( String args[]){         int a[]= new int[] {0,-9,3,2,-4,3,-12,3,1};         functionOfA( a);         for( int i= 0; i< a.length; i++){             System.out.print( a[i]+ " ");         }         System.out.println();         System.out.println();         int a2[]= new int[] {-9,-3,-10,-4,-2};         functionOfA( a2);         for( int i2= 0; i2< a2.length; i2++){             System.out.print( a2[i2]+ " ");         }     } }```