https://gcreddy.info/java-tutorial-for-beginners/

Java Language Syllabus
https://gcreddy.info/java-language-syllabus/

1. Introduction to Java Programming
https://gcreddy.info/introduction-to-java-programming/

2. Java Environment Setup
https://gcreddy.info/java-environment-setup/

3. Java Keywords and Identifiers
https://gcreddy.info/java-keywords-and-identifiers/

4. Java Program Structure
https://gcreddy.info/java-program-structure/

5. Java Comments
https://gcreddy.info/java-comments/

6. Java Data Types
https://gcreddy.info/java-data-types/

7. Java Variables
https://gcreddy.info/java-variables/

8. Operators in Java
https://gcreddy.info/operators-in-java/

9. Java Control Flow Statements
https://gcreddy.info/java-control-flow-statements/

10. Java Strings
https://gcreddy.info/java-strings/

11. Arrays in Java
https://gcreddy.info/arrays-in-java/

12. Java ArrayList
https://gcreddy.info/java-arraylist/

13. Java Input and Output
https://gcreddy.info/java-input-and-output/

14. Java User Defined Methods
https://gcreddy.info/java-user-defined-methods/

15. Java Built-in Methods
https://gcreddy.info/java-built-in-methods/

16. Exception Handling in Java
https://gcreddy.info/exception-handling-in-java/

17. Java Object-Oriented Programming
https://gcreddy.info/java-object-oriented-programming/

Input and Output in Java
Read User Input
Write Program's Output
Read Files
Write Files

Read User Input

The 'Scanner' class is used to get user input, and it is found in the 'util' package
java.util.Scanner

To use the 'Scanner' class, create an object of the class and use any of the available methods found in Scanner class documentation.

Input Types

Method Description
1. nextLine() Reads a String type value from the User
2. nextByte() Reads a Byte type value from the User
3. nextShort() Reads a Short type value from the User
4. nextInt() Reads an Int type value from the User
5. nextLong() Reads a Long type value from the User
6. nextFloat() Reads a Float type value from the User
7. nextDouble() Reads a Double type value from the User
8. nextBoolean() Reads a Boolean type value from the User
9. next().charAt(index) Reads a Character type value from the User

Java Example for Reading user input:

import java.util.Scanner;

public class Sample {

public static void main(String[] args) {
Scanner scan = new Scanner(System.in);

System.out.println("Enter Your name: ");
String name = scan.nextLine();
System.out.println("Your name is: "+name);

System.out.println("Enter a Number: ");
int num = scan.nextInt();
System.out.println("The number is: "+num);

System.out.println("Enter your Mobile Number: ");
long mobileNum = scan.nextLong();
System.out.println("Your Mobile number is: "+mobileNum);

System.out.println("Read a Number with decimal places: ");
double num2 = scan.nextDouble();
System.out.println("The number is: "+num2);

System.out.println("Enter a Value: ");
boolean val = scan.nextBoolean();
System.out.println("Your Val is: "+val);

System.out.println("Read a Character: ");
char myChar = scan.next().charAt(0);
System.out.println("The character value is: "+myChar);
}
}