problems with array index
I have a vector
I try to print out the smallest number After compiling I get this messege: Arrays index is out of bound Exception.
what's the problem?
Code:
class VectorTest{
public static void main(String[]args){
int smallestvalue=Integer.MAX_VALUE;
int lastvalue;
int currentvalue;
int []v={5,3,6,0};
int i=0;
while(i>=0){
currentvalue= v[i+1];
lastvalue= v[ i ];
if(current>last){
smallestvalue=lastvalue;
}else{
smallestvalue=currentvalue;
}
i++;
}
System.out.println(smallest);
}
}