[code]
Hi!
I have a vector ( int []v={4,13,6,2}
I try to print out the smallest number(2). After compiling I get this messege: Arrays index is out of bound Exception.
I try also to print out the vector like this:2,4,6,13.
How do I solve these problems.
------------------------------------------------------

class MyVector{
public static void main(String[]args){
int smallest=Integer.MAX_VALUE;
int last;
int current;
int []v={4,13,6,2};
int i=0;
while(i>=0){
current= v[i+1];
last= v[ i ];

if(current>last){
smallest=last;
}else{
smallest=current;
}
i++;
}
System.out.println(smallest);
}
}

[code]