SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
1
JAVA Programming :
Scanner class
Handled By
Dr.T.Abirami
Associate Professor
Department of IT
Kongu Engineering College Perundurai
Dr.T.Abirami/Department of IT
User Input
2
 The Scanner class is used to get user
input, and it is found in
the java.util package.
Dr.T.Abirami/Department of IT
Scanner class Methods
3
Method Description
nextBoolean() Reads a boolean value from the user
nextByte() Reads a byte value from the user
nextDouble() Reads a double value from the user
nextFloat() Reads a float value from the user
nextInt() Reads a int value from the user
nextLine()
next()
Reads a String value from the user
nextLong() Reads a long value from the user
nextShort() Reads a short value from the user
Dr.T.Abirami/Department of IT
Example:
4
Class sample
{
Public static
Dr.T.Abirami/Department of IT
Strings
 The String data type is used to store a
sequence of characters (text).
 String values must be surrounded by
double quotes:
Example
 String greeting = "Hello World";
System.out.println(greeting);
5
Dr.T.Abirami/Department of IT
Example:
6
Class sample
{
Public static
Dr.T.Abirami/Department of IT
import java.util.Scanner;
class GetInputData
{
public static void main(String args[])
{
int num;
float fnum;
String str;
Scanner in = new Scanner(System.in);
//Get input String
System.out.println("Enter a string: ");
str = in.nextLine();
System.out.println("Input String is: "+str);
//Get input Integer
System.out.println("Enter an integer: ");
num = in.nextInt();
System.out.println("Input Integer is: "+num);
//Get input float number
System.out.println("Enter a float number: ");
fnum = in.nextFloat();
System.out.println("Input Float number is: "+fnum);
}
}
7
Dr.T.Abirami/Department of IT

More Related Content

PDF
Object oriented programming c++
Ankur Pandey
 
PPSX
Data Types & Variables in JAVA
Ankita Totala
 
PPT
Scanner class
M Vishnuvardhan Reddy
 
PPTX
Constructor ppt
Vinod Kumar
 
PPS
Wrapper class
kamal kotecha
 
PPTX
virtual function
VENNILAV6
 
PPTX
Packages in java
Elizabeth alexander
 
PPTX
Inline function in C++
Jenish Patel
 
Object oriented programming c++
Ankur Pandey
 
Data Types & Variables in JAVA
Ankita Totala
 
Scanner class
M Vishnuvardhan Reddy
 
Constructor ppt
Vinod Kumar
 
Wrapper class
kamal kotecha
 
virtual function
VENNILAV6
 
Packages in java
Elizabeth alexander
 
Inline function in C++
Jenish Patel
 

What's hot (20)

PPT
Looping statements in Java
Jin Castor
 
PPTX
Methods in java
chauhankapil
 
PPTX
class and objects
Payel Guria
 
PPTX
Java OOP
Muhammed YALÇIN
 
PPTX
Java awt (abstract window toolkit)
Elizabeth alexander
 
PPT
Java Streams
M Vishnuvardhan Reddy
 
PPTX
Constructor in java
Pavith Gunasekara
 
PPT
9. Input Output in java
Nilesh Dalvi
 
PPT
Method overriding
Azaz Maverick
 
PDF
Java conditional statements
Kuppusamy P
 
PPTX
Storage class in C Language
Nitesh Kumar Pandey
 
PPTX
Function in C program
Nurul Zakiah Zamri Tan
 
PPTX
Data Types and Variables In C Programming
Kamal Acharya
 
PPTX
Data Types, Variables, and Operators
Marwa Ali Eissa
 
PDF
input/ output in java
sharma230399
 
PPTX
constructors in java ppt
kunal kishore
 
PPSX
Modules and packages in python
TMARAGATHAM
 
PPT
Java interfaces
Raja Sekhar
 
PPTX
Operators in java
Then Murugeshwari
 
PPTX
Operators in java presentation
kunal kishore
 
Looping statements in Java
Jin Castor
 
Methods in java
chauhankapil
 
class and objects
Payel Guria
 
Java awt (abstract window toolkit)
Elizabeth alexander
 
Java Streams
M Vishnuvardhan Reddy
 
Constructor in java
Pavith Gunasekara
 
9. Input Output in java
Nilesh Dalvi
 
Method overriding
Azaz Maverick
 
Java conditional statements
Kuppusamy P
 
Storage class in C Language
Nitesh Kumar Pandey
 
Function in C program
Nurul Zakiah Zamri Tan
 
Data Types and Variables In C Programming
Kamal Acharya
 
Data Types, Variables, and Operators
Marwa Ali Eissa
 
input/ output in java
sharma230399
 
constructors in java ppt
kunal kishore
 
Modules and packages in python
TMARAGATHAM
 
Java interfaces
Raja Sekhar
 
Operators in java
Then Murugeshwari
 
Operators in java presentation
kunal kishore
 
Ad

Similar to Scanner class java (20)

PPTX
scan.pptx
WrushabhShirsat3
 
PPTX
Computer programming 2 chapter 1-lesson 2
MLG College of Learning, Inc
 
PPTX
Handling inputs via scanner class
simarsimmygrewal
 
PPTX
Java input
Jin Castor
 
PDF
3.Lesson Plan - Input.pdf.pdf
AbhishekSingh757567
 
PDF
djkkfhulkgyftfdtrdrsdsjjjjjjjjjjjjjjjjjjj
AbhishekSingh757567
 
PPTX
Scannerclass
jagriti srivastava
 
PPT
ppt on scanner class
deepsxn
 
DOCX
How to get input from usjer in Java.docx
pranauvsps
 
PPTX
Lab 01jbjbjkbkbjkbkjbkjbkbkjbbnjjkb.pptx
abdulbasetalselwi
 
PPTX
Lab 01hhkhkhkhkhkhkhkhkhjjjkhkkhhhhh.pptx
abdulbasetalselwi
 
PPTX
JAVA_SAMPLE CODING, JAVA BASICS PROGRAMS.pptx
SrinivasGopalan2
 
PPTX
Lecture 3.pptx
ShehabEldinSaid
 
PPTX
Chapter 3.4
sotlsoc
 
PDF
Lecture 2 java.pdf
SantoshSurwade2
 
PPT
07-Basic-Input-Output.ppt
Ajenkris Kungkung
 
PPT
Introduction to Java Programming Part 2
university of education,Lahore
 
PPTX
DSA 103 Object Oriented Programming :: Week 4
Ferdin Joe John Joseph PhD
 
PPTX
Java - Basic Datatypes.pptx
Nagaraju Pamarthi
 
PDF
Java q ref 2018
Christopher Akinlade
 
scan.pptx
WrushabhShirsat3
 
Computer programming 2 chapter 1-lesson 2
MLG College of Learning, Inc
 
Handling inputs via scanner class
simarsimmygrewal
 
Java input
Jin Castor
 
3.Lesson Plan - Input.pdf.pdf
AbhishekSingh757567
 
djkkfhulkgyftfdtrdrsdsjjjjjjjjjjjjjjjjjjj
AbhishekSingh757567
 
Scannerclass
jagriti srivastava
 
ppt on scanner class
deepsxn
 
How to get input from usjer in Java.docx
pranauvsps
 
Lab 01jbjbjkbkbjkbkjbkjbkbkjbbnjjkb.pptx
abdulbasetalselwi
 
Lab 01hhkhkhkhkhkhkhkhkhjjjkhkkhhhhh.pptx
abdulbasetalselwi
 
JAVA_SAMPLE CODING, JAVA BASICS PROGRAMS.pptx
SrinivasGopalan2
 
Lecture 3.pptx
ShehabEldinSaid
 
Chapter 3.4
sotlsoc
 
Lecture 2 java.pdf
SantoshSurwade2
 
07-Basic-Input-Output.ppt
Ajenkris Kungkung
 
Introduction to Java Programming Part 2
university of education,Lahore
 
DSA 103 Object Oriented Programming :: Week 4
Ferdin Joe John Joseph PhD
 
Java - Basic Datatypes.pptx
Nagaraju Pamarthi
 
Java q ref 2018
Christopher Akinlade
 
Ad

More from Kongu Engineering College, Perundurai, Erode (20)

PPTX
Event Handling -_GET _ POSTimplementation.pptx
Kongu Engineering College, Perundurai, Erode
 
PPTX
Introduction to Generative AI refers to a subset of artificial intelligence
Kongu Engineering College, Perundurai, Erode
 
PPTX
Introduction to Microsoft Power BI is a business analytics service
Kongu Engineering College, Perundurai, Erode
 
PPTX
Connect to NoSQL Database (MongoDB) using Node JS & Connect Node.js with NoSQ...
Kongu Engineering College, Perundurai, Erode
 
PPTX
concept of server-side JavaScript / JS Framework: NODEJS
Kongu Engineering College, Perundurai, Erode
 
PPTX
Node.js web-based Example :Run a local server in order to start using node.js...
Kongu Engineering College, Perundurai, Erode
 
PPT
Concepts of Satellite Communication and types and its applications
Kongu Engineering College, Perundurai, Erode
 
PPT
Concepts of Mobile Communication Wireless LANs, Bluetooth , HiperLAN
Kongu Engineering College, Perundurai, Erode
 
PPTX
Web Technology Introduction framework.pptx
Kongu Engineering College, Perundurai, Erode
 
PPTX
Computer Network - Unicast Routing Distance vector Link state vector
Kongu Engineering College, Perundurai, Erode
 
PPT
Android SQLite database oriented application development
Kongu Engineering College, Perundurai, Erode
 
PPT
Android Application Development Programming
Kongu Engineering College, Perundurai, Erode
 
PPTX
Introduction to Spring & Spring BootFramework
Kongu Engineering College, Perundurai, Erode
 
PPTX
A REST API (also called a RESTful API or RESTful web API) is an application p...
Kongu Engineering College, Perundurai, Erode
 
PPTX
SOA and Monolith Architecture - Micro Services.pptx
Kongu Engineering College, Perundurai, Erode
 
PPTX
Connect to NoSQL Database using Node JS.pptx
Kongu Engineering College, Perundurai, Erode
 
PPTX
Bootstarp installation.pptx
Kongu Engineering College, Perundurai, Erode
 
Event Handling -_GET _ POSTimplementation.pptx
Kongu Engineering College, Perundurai, Erode
 
Introduction to Generative AI refers to a subset of artificial intelligence
Kongu Engineering College, Perundurai, Erode
 
Introduction to Microsoft Power BI is a business analytics service
Kongu Engineering College, Perundurai, Erode
 
Connect to NoSQL Database (MongoDB) using Node JS & Connect Node.js with NoSQ...
Kongu Engineering College, Perundurai, Erode
 
concept of server-side JavaScript / JS Framework: NODEJS
Kongu Engineering College, Perundurai, Erode
 
Node.js web-based Example :Run a local server in order to start using node.js...
Kongu Engineering College, Perundurai, Erode
 
Concepts of Satellite Communication and types and its applications
Kongu Engineering College, Perundurai, Erode
 
Concepts of Mobile Communication Wireless LANs, Bluetooth , HiperLAN
Kongu Engineering College, Perundurai, Erode
 
Web Technology Introduction framework.pptx
Kongu Engineering College, Perundurai, Erode
 
Computer Network - Unicast Routing Distance vector Link state vector
Kongu Engineering College, Perundurai, Erode
 
Android SQLite database oriented application development
Kongu Engineering College, Perundurai, Erode
 
Android Application Development Programming
Kongu Engineering College, Perundurai, Erode
 
Introduction to Spring & Spring BootFramework
Kongu Engineering College, Perundurai, Erode
 
A REST API (also called a RESTful API or RESTful web API) is an application p...
Kongu Engineering College, Perundurai, Erode
 
SOA and Monolith Architecture - Micro Services.pptx
Kongu Engineering College, Perundurai, Erode
 
Connect to NoSQL Database using Node JS.pptx
Kongu Engineering College, Perundurai, Erode
 

Recently uploaded (20)

PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
Zero Carbon Building Performance standard
BassemOsman1
 
PDF
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
PDF
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
PPTX
database slide on modern techniques for optimizing database queries.pptx
aky52024
 
PDF
Advanced LangChain & RAG: Building a Financial AI Assistant with Real-Time Data
Soufiane Sejjari
 
PDF
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
PDF
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
PPTX
sunil mishra pptmmmmmmmmmmmmmmmmmmmmmmmmm
singhamit111
 
PPTX
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
PDF
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
PPTX
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
DOCX
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
PPTX
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
PDF
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
PPTX
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 
PPTX
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
PPTX
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Zero Carbon Building Performance standard
BassemOsman1
 
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
database slide on modern techniques for optimizing database queries.pptx
aky52024
 
Advanced LangChain & RAG: Building a Financial AI Assistant with Real-Time Data
Soufiane Sejjari
 
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
sunil mishra pptmmmmmmmmmmmmmmmmmmmmmmmmm
singhamit111
 
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 

Scanner class java

  • 1. 1 JAVA Programming : Scanner class Handled By Dr.T.Abirami Associate Professor Department of IT Kongu Engineering College Perundurai Dr.T.Abirami/Department of IT
  • 2. User Input 2  The Scanner class is used to get user input, and it is found in the java.util package. Dr.T.Abirami/Department of IT
  • 3. Scanner class Methods 3 Method Description nextBoolean() Reads a boolean value from the user nextByte() Reads a byte value from the user nextDouble() Reads a double value from the user nextFloat() Reads a float value from the user nextInt() Reads a int value from the user nextLine() next() Reads a String value from the user nextLong() Reads a long value from the user nextShort() Reads a short value from the user Dr.T.Abirami/Department of IT
  • 5. Strings  The String data type is used to store a sequence of characters (text).  String values must be surrounded by double quotes: Example  String greeting = "Hello World"; System.out.println(greeting); 5 Dr.T.Abirami/Department of IT
  • 7. import java.util.Scanner; class GetInputData { public static void main(String args[]) { int num; float fnum; String str; Scanner in = new Scanner(System.in); //Get input String System.out.println("Enter a string: "); str = in.nextLine(); System.out.println("Input String is: "+str); //Get input Integer System.out.println("Enter an integer: "); num = in.nextInt(); System.out.println("Input Integer is: "+num); //Get input float number System.out.println("Enter a float number: "); fnum = in.nextFloat(); System.out.println("Input Float number is: "+fnum); } } 7 Dr.T.Abirami/Department of IT