title: I can't get the output for the vector
body: <p>Supposedly,this program allows us to store data into the vector.We can keep on entering integers and then the program terminates when there is a non-integer.The program is supposed to print the largest value entered.
  ****however when I run this code below,I can only keep on entering the integers.And when I enter a non-integer,it gives a list of errors.</p>
  
  <p>My code is(I'm not sure if Im running it correctly):</p>
  
  <pre><code>package javaapplication58;
  
  import java.util.Scanner;
  import java.util.Vector;
  
  public class JavaApplication58 {
  
  
          public static void main(String[] args) {
              Vector &lt;Integer&gt; v=new Vector();
              v=readInVectorOfIntegers();
              System.out.println(largest(v));
  
             }
          public static Vector  &lt;Integer&gt; readInVectorOfIntegers()
          {Scanner in=new Scanner(System.in);
          Vector&lt;Integer&gt;w=new Vector ();
          while (in.hasNextLine())w.addElement(in.nextInt());
          return w;
  
          }
  
          public static int largest(Vector &lt;Integer&gt; v)
          {int largestsofar;
          if(v.size()&gt;0){largestsofar=v.elementAt(0);
          for (int i=0;i&lt;v.size();i++)
              if(largestsofar&lt;v.elementAt(i))
               largestsofar=v.elementAt(i);
          return largestsofar;
  
  
          }
  
          return 0;
  
  
          }
      }
  </code></pre>