for (int i = 0; i <10; i++)
{
Float temp = scanner.nextFloat();
vec.add(temp);
}
if you want that when user enter any number loop will terminate without adding that number into vector.
then check inside the loop if the number is negative break;
for (int i = 0; i <10; i++)
{
Float temp = scanner.nextFloat();
if(temp<0)
break;
vec.add(temp);
}
and if you want that number entered negative should be the last number entered in the vector.
then check the condition like:
intitalize
temp =0
for (int i = 0; i <10 && temp>=0; i++)