Is there a function with the scanner class to allow for the user's input to just go on one line instead of two.

I am using Scanner scan = new Scanner (System.in)

with scan.nextInt

and it is coming up with

10
4

and I want it to appear on one line with a space like 10 4

Thank you

This works...try this

import java.util.*;
class  ScannerDemo{

    public static void main(String[] args) 
    {
        System.out.println("please enter some thing");
        Scanner s=new Scanner(System.in);
        while(s.hasNext()){
            System.out.print(s.nextInt()+" ");
        }//end of while

    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.