Read something in the same print line


I am beginner in JAVA programming and I was wondering about how can I read a number (or character) in same line that I’ve print a question


 (number to be imputed) : (number to be imputed) : (number to be imputed)


Use print method, it will not change the line and you can enter the number in the same line

import java.util.Scanner;
public class Main {

  public static void main(String[] args) {
    Scanner input = new Scanner(;
    System.out.print("enter an number : ");

Source: stackoverflow