Search:

Type: Posts; User: Norm

Search: Search took 0.20 seconds.

  1. Re: Integer values from a mixed textfile in Java using Scanner

    if(s.hasNextInt())
    {
    Out.println("Int: " + s.nextInt()); // Reads the int found by hasNextInt
    ArrayInt.add(s.nextInt()); // This reads the next value. What is it??

    The...
  2. Re: Integer values from a mixed textfile in Java using Scanner

    The call to hasNext() does NOT read anything. Use next() to read the non-integer.
    For debugging add a print statement that prints out the values that were skipped.
  3. Re: Integer values from a mixed textfile in Java using Scanner

    The Scanner class has methods that will tell you what data type the next token to be read is. Look at the hasNext... methods.
    If you only want to read integer values, use the hasNextInt method to...
Results 1 to 3 of 3