Java Programming - How to get User Input

Опубликовано: 16 Май 2026
на канале: Simple Tutorials
10
1

This video will help you create a Class that can be used for getting user inputs.
Here is the code:
public class UserInput {

private Scanner sc;

public UserInput() {
this.sc=new Scanner(System.in);
}

public String getUserText() {
String temp=this.sc.nextLine();
return temp;
}

public int getUserInt() {
int temp=this.sc.nextInt();
return temp;
}

public float getUserFloat() {
float temp=this.sc.nextFloat();
return temp;
}
}