0% found this document useful (0 votes)
4 views12 pages

std 9 input in java

The document discusses various methods for input in Java, including assignment, function arguments, and the Scanner class. It details the Scanner class, its importation, and its methods for receiving different types of input. Additionally, it outlines the types of errors that can occur in Java programming: syntax, logical, and runtime errors.

Uploaded by

devishankar4499
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views12 pages

std 9 input in java

The document discusses various methods for input in Java, including assignment, function arguments, and the Scanner class. It details the Scanner class, its importation, and its methods for receiving different types of input. Additionally, it outlines the types of errors that can occur in Java programming: syntax, logical, and runtime errors.

Uploaded by

devishankar4499
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

INPUT IN JAVA

CHAPTER - 4
COMMENT

Non-executable statement
Types of Comment
1. Single Line Comment //
2. Multi line Comment /* …………. */
3. Documentation Comment /**
……………….. */
INPUT IN JAVA

1. Input by using Assignment

2. Input by using Function Argument

3. Input by using Scanner Class

4. Input by using InputStreamReader


INPUT BY USING ASSIGNMENT METHOD
INPUT BY USING FUNCTION ARGUMENT
INPUT BY USING FUNCTION ARGUMENT
INPUT USING SCANNER CLASS
● Latest development in Java

● Scanner class is a built-in class in JDK 1.5

● Scanner class is present in java.util package.


Import a System class
in Program

import java.util.Scanner;

Or

import java.util.*;
SCANNER CLASS
Scanner in=new Scanner(System.in);

o System.in : used to allow the program to receive data


from the keyboard.
o Scanner class works based on Token
o Each token/input can be separated by a blank space
or enter key.
o Other separator/ delimiters are . , ; ? ! White space
SCANNER CLASS METHODS
1. nextShort( )
2. nextInt( )
3. nextFloat( )
4. nextDouble( )
5. nextLong( )
6. next( ) - to accept a word
7. nextLine( ) -to accept a sentence
8. next.charAt(0) - to accept a character
Java program using
Scanner Class
TYPES OF ERRORS

1. Syntax Error
2. Logical Error
3. Run time Error

You might also like