Use Scanner.

You can see this tutorial https://www.w3schools.com/java/java_user_input.asp