




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Introduction to Input and Output (^) Input means accepting data from the user. (^) Output means displaying results to the user. Java provides different classes for input. (^) Output is displayed using System.out. (^) Input and Output are essential in every Java program.
Scanner Class (^) Available in java.util package. (^) Reads user input easily. (^) Supports different data types. (^) Suitable for beginners. (^) Most commonly used input method. Syntax (^) import java.util.Scanner; (^) Scanner sc = new Scanner(System.in);
Scanner Methods (^) nextInt() → Integer (^) nextDouble() → Decimal (^) next() → Single word (^) nextLine() → Full sentence (^) nextBoolean() → Boolean value Example (^) int age = sc.nextInt(); (^) String name = sc.next();
BufferedReader Class (^) Available in java.io package. (^) Faster than Scanner. (^) Reads text as characters. (^) Requires exception handling. (^) Mostly used for large inputs (^). Syntax (^) import java.io.*; (^) BufferedReader br = (^) new BufferedReader(new InputStreamReader(System.in));
Console Class (^) Available in java.io. (^) Reads input from console. (^) Password input is hidden. (^) Not supported in many IDEs. (^) Mostly used in command prompt. Syntax (^) Console c = System.console(); (^) String name = c.readLine();
Scanner Class Introduction (^) Reads user input. (^) Located in java.util. (^) Object creation required. (^) Supports all primitive types. (^) Easy to use.
Import Scanner (^) Import package. (^) Create Scanner object. (^) Connect with keyboard. (^) Ready to receive input. (^) Close Scanner after use. (^) import java.util.Scanner; (^) Scanner sc = new Scanner(System.in);
Reading Decimal (^) Uses nextDouble() (^) Reads decimal numbers. (^) Stores in double. (^) Used for marks. (^) Used for salary. (^) double salary=sc.nextDouble();
Reading String (^) next() (^) Reads one word. (^) Stops at space. (^) Fast input. (^) Used for names. (^) String name=sc.next();
Method Purpose nextInt() Integer nextDouble() Decimal next() Word nextLine() Sentence nextBoolean() Boolean
Advantages (^) Easy syntax. (^) Beginner-friendly. (^) Supports all data types. (^) Less coding. (^) Widely used.
Introduction to BufferedReader (^) Used to read character input efficiently. (^) Available in the java.io package. (^) Reads input as text (String). (^) Faster than Scanner for large input. (^) Mainly used in competitive and file programming.
Features of BufferedReader (^) High-speed input. (^) Reads complete line of text. (^) Uses character buffering. (^) Supports file and keyboard input. (^) Requires exception handling.