SlideShare a Scribd company logo
Rohan K.Gajre.
what is the meaning of true object
oriented
If we want to do anything in java must be
within a class
what is the meaning of
program compilation
Compilation means to convert your actual
programme or source code in to the
machine code or byte code
Machine code machine independent
Run or execute on any operating system
or plat forms is called as platform
independent this is a feature of java
what is public static void
main(String x[])
This is the main function of java same like
as main function in c
Static content can share all members in
application so main is available in whole
application
Static content load in memory very first
when program run. for program execution
main method must be load in memory so
main is static
what is String x[]
This is a command line argument in java
If we pass the any parameter to main
function is called as command line
argument
what is the use of command line argument in
java
To provide the run time input
e.g.
class Firstprog
{
public static void main(String x[])
{
System.out.println(“Hi I am java");
}
}
How to cross check byte code
created or not
After the program compile java create
the one new file automatically is called
as .class file and in this file contain byte
code
Use the command line argument
If you want provide the input at run
time
Use the command line argument
Or
Java provide the some inbuilt classes for
input. Command line argument is infinite
string array means we can pass the n
number of input through the command line
argument but the first input start with
zero index(basic array rule)
type casting
how to perform the type casting or
type conversion in java
for that java provide some inbuilt classes
for conversion is called as wrapper classes
syntax -->
integervariable=Integer.parseInt(value for conversion|);
e.g. a=Integer.parseInt(x[0]);
Integer is a class in java and parseInt() is
the static method of Integer class this
method is used to convert the any value.
floatvriable=Float.parseFloat(value);
or
Float.valueOf(value).floatValue();
public class FirstBatch{
public static void main(String x[])
{ int a,b,c;
a=Integer.parseInt(x[0]);
b=Integer.parseInt(x[1]);
c=a+b;
System.out.println("Addition is "+c);
}
}
DataInputStream
This class is used to accept the input
from keyboard same like as scanf() in c
this class is a member of java.io package
 To add follow some step’s
Add java.io. pacakge in programme
package is a collection of classes same like
as header file in c
header file is a collection of functions in c
import packagename;
e.g. import java.io.*; -->this statement
allow us to use all classes present in
java.io.
import java.io.DataInputStream;-->we can
use only one class in program from java.io
package
import is the keyword in java which is used
to add the package in program
create the object of DataInputStream
class
if we want to use the class and its
member any where for that we need to
object
Synatx
DataInputStream objectname=new DataInputStream(System.in);
Or
DataInputStream objectname;
objectname=new DataInputStream(System.in); 
E.g..
DataInputStream input=new
DataInputStream(System.in);
use its readLine() method for input
readLine() is the method of
DataInputStream class which is used to
accept the input from keyboard
Use of readLine() method
objectofdatainputstream.readLine()
//P1 import java.io.*;
public class DataFirst
{
public static void main(String x[])throws
Exception
{
DataInputStream xyz=new DataInputStream(System.in);
int num,sq;
System.out.println("Enter the number");
num=Integer.parseInt(xyz.readLine());
sq=num*num;
System.out.println("square is "+sq);
}
}
//P2
import java.io.*;
public class Student
{
public static void main(String x[])throws Exception
{
DataInputStream input=new DataInputStream(System.in);
int number;
String name;
float marks;
System.out.println("enter the name of student");
name=input.readLine();
System.out.println("Enter the id of student");
number=Integer.parseInt(input.readLine());
System.out.println("Enter the marks of student");
}
marks=Float.valueOf(input.readLine()).floatValue();
System.out.println("Name of student "+name);
System.out.println("Id of student is "+number);
System.out.println("Marks of student is "+marks);
}
Problem with readLine() method
Need to convert for every input other than
string for that java provide the another
optional class for input to us Scanner .
Scanner is a class same like as
DataInputStram Scanner is a member of
java.util package
 add the util package in programme
import java.util.*;
create the object of Scanner class
Scanner object=new Scanner(System.in);
e.g Scanner input=new Scanner(System.in);
Use its following method for input
nextInt() --> for integer input
nextFloat() ---> for float input
nextDouble() --> for double input
nextByte() --> for byte input
nextLine() ----> for string input
nextShort() -->short integer input
nextLong() ---> for long integer input
import java.util.*;
public class ScannerApp
{
public static void main(String x[])
{
Scanner xyz=new Scanner(System.in);
int id;
float marks;
String name;
System.out.println("Enter the name ");
name=xyz.nextLine();
System.out.println("enter the id ");
id=xyz.nextInt();
System.out.println("enter the marks ");
marks=xyz.nextFloat();
System.out.println("Name is "+name);
System.out.println("Id is "+id);
System.out.println("Marks is "+marks);
}
}
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt
Java ppt

More Related Content

What's hot

Python basic
Python basicPython basic
Python basic
Saifuddin Kaijar
 
JAVA FEATURES
JAVA FEATURESJAVA FEATURES
JAVA FEATURES
shalinikarunakaran1
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
Muhammad Waqas
 
Introduction to Java -unit-1
Introduction to Java -unit-1Introduction to Java -unit-1
Introduction to Java -unit-1
RubaNagarajan
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Conceptsthinkphp
 
Java Data Types
Java Data TypesJava Data Types
Java Data Types
Spotle.ai
 
Applets in java
Applets in javaApplets in java
Applets in java
Wani Zahoor
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
Pooja Jaiswal
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVA
Ankita Totala
 
Basic of Java
Basic of JavaBasic of Java
Basic of Java
Ajeet Kumar Verma
 
Java Methods
Java MethodsJava Methods
Java MethodsOXUS 20
 
Java package
Java packageJava package
Java package
CS_GDRCST
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
RahulAnanda1
 
Java Tutorial Lab 1
Java Tutorial Lab 1Java Tutorial Lab 1
Java Tutorial Lab 1
Berk Soysal
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
Intelligo Technologies
 
Java constructors
Java constructorsJava constructors
Java constructors
QUONTRASOLUTIONS
 

What's hot (20)

Python basic
Python basicPython basic
Python basic
 
JAVA FEATURES
JAVA FEATURESJAVA FEATURES
JAVA FEATURES
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
 
Oop concepts in python
Oop concepts in pythonOop concepts in python
Oop concepts in python
 
Java
JavaJava
Java
 
Introduction to Java -unit-1
Introduction to Java -unit-1Introduction to Java -unit-1
Introduction to Java -unit-1
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Java Data Types
Java Data TypesJava Data Types
Java Data Types
 
Applets in java
Applets in javaApplets in java
Applets in java
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Features of java
Features of javaFeatures of java
Features of java
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVA
 
Basic of Java
Basic of JavaBasic of Java
Basic of Java
 
Java Methods
Java MethodsJava Methods
Java Methods
 
Java package
Java packageJava package
Java package
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Java Tutorial Lab 1
Java Tutorial Lab 1Java Tutorial Lab 1
Java Tutorial Lab 1
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Java constructors
Java constructorsJava constructors
Java constructors
 

Similar to Java ppt

Java Programs
Java ProgramsJava Programs
Java Programs
vvpadhu
 
Computer programming 2 chapter 1-lesson 2
Computer programming 2  chapter 1-lesson 2Computer programming 2  chapter 1-lesson 2
Computer programming 2 chapter 1-lesson 2
MLG College of Learning, Inc
 
Java programs
Java programsJava programs
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streamsShahjahan Samoon
 
Object oriented programming la bmanual jntu
Object oriented programming la bmanual jntuObject oriented programming la bmanual jntu
Object oriented programming la bmanual jntuKhurshid Asghar
 
Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]Palak Sanghani
 
New features and enhancement
New features and enhancementNew features and enhancement
New features and enhancementRakesh Madugula
 
Reading and writting v2
Reading and writting v2Reading and writting v2
Reading and writting v2ASU Online
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentalsHCMUTE
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
Maýur Chourasiya
 
Learning Java 1 – Introduction
Learning Java 1 – IntroductionLearning Java 1 – Introduction
Learning Java 1 – Introduction
caswenson
 
final year project center in Coimbatore
final year project center in Coimbatorefinal year project center in Coimbatore
final year project center in Coimbatore
cbeproject centercoimbatore
 
Java 8 new features
Java 8 new featuresJava 8 new features
Java 8 new features
Aniket Thakur
 
Class notes(week 5) on command line arguments
Class notes(week 5) on command line argumentsClass notes(week 5) on command line arguments
Class notes(week 5) on command line arguments
Kuntal Bhowmick
 
Class notes(week 5) on command line arguments
Class notes(week 5) on command line argumentsClass notes(week 5) on command line arguments
Class notes(week 5) on command line arguments
Kuntal Bhowmick
 
02basics
02basics02basics
02basics
Waheed Warraich
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
Van Huong
 

Similar to Java ppt (20)

Java Programs
Java ProgramsJava Programs
Java Programs
 
Computer programming 2 chapter 1-lesson 2
Computer programming 2  chapter 1-lesson 2Computer programming 2  chapter 1-lesson 2
Computer programming 2 chapter 1-lesson 2
 
Java 5 and 6 New Features
Java 5 and 6 New FeaturesJava 5 and 6 New Features
Java 5 and 6 New Features
 
Java programs
Java programsJava programs
Java programs
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streams
 
Object oriented programming la bmanual jntu
Object oriented programming la bmanual jntuObject oriented programming la bmanual jntu
Object oriented programming la bmanual jntu
 
Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]Lec 5 13_aug [compatibility mode]
Lec 5 13_aug [compatibility mode]
 
New features and enhancement
New features and enhancementNew features and enhancement
New features and enhancement
 
Reading and writting v2
Reading and writting v2Reading and writting v2
Reading and writting v2
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Core java
Core javaCore java
Core java
 
Learning Java 1 – Introduction
Learning Java 1 – IntroductionLearning Java 1 – Introduction
Learning Java 1 – Introduction
 
final year project center in Coimbatore
final year project center in Coimbatorefinal year project center in Coimbatore
final year project center in Coimbatore
 
Java 8 new features
Java 8 new featuresJava 8 new features
Java 8 new features
 
Class notes(week 5) on command line arguments
Class notes(week 5) on command line argumentsClass notes(week 5) on command line arguments
Class notes(week 5) on command line arguments
 
Class notes(week 5) on command line arguments
Class notes(week 5) on command line argumentsClass notes(week 5) on command line arguments
Class notes(week 5) on command line arguments
 
02basics
02basics02basics
02basics
 
Core java Essentials
Core java EssentialsCore java Essentials
Core java Essentials
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
 

Recently uploaded

Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
DhatriParmar
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 

Recently uploaded (20)

Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 

Java ppt

  • 2. what is the meaning of true object oriented If we want to do anything in java must be within a class
  • 3. what is the meaning of program compilation Compilation means to convert your actual programme or source code in to the machine code or byte code Machine code machine independent Run or execute on any operating system or plat forms is called as platform independent this is a feature of java
  • 4. what is public static void main(String x[]) This is the main function of java same like as main function in c Static content can share all members in application so main is available in whole application Static content load in memory very first when program run. for program execution main method must be load in memory so main is static
  • 5. what is String x[] This is a command line argument in java If we pass the any parameter to main function is called as command line argument what is the use of command line argument in java To provide the run time input
  • 6. e.g. class Firstprog { public static void main(String x[]) { System.out.println(“Hi I am java"); } }
  • 7. How to cross check byte code created or not After the program compile java create the one new file automatically is called as .class file and in this file contain byte code Use the command line argument
  • 8. If you want provide the input at run time Use the command line argument Or Java provide the some inbuilt classes for input. Command line argument is infinite string array means we can pass the n number of input through the command line argument but the first input start with zero index(basic array rule)
  • 9. type casting how to perform the type casting or type conversion in java for that java provide some inbuilt classes for conversion is called as wrapper classes syntax --> integervariable=Integer.parseInt(value for conversion|); e.g. a=Integer.parseInt(x[0]);
  • 10. Integer is a class in java and parseInt() is the static method of Integer class this method is used to convert the any value. floatvriable=Float.parseFloat(value); or Float.valueOf(value).floatValue();
  • 11. public class FirstBatch{ public static void main(String x[]) { int a,b,c; a=Integer.parseInt(x[0]); b=Integer.parseInt(x[1]); c=a+b; System.out.println("Addition is "+c); } }
  • 12. DataInputStream This class is used to accept the input from keyboard same like as scanf() in c this class is a member of java.io package  To add follow some step’s Add java.io. pacakge in programme package is a collection of classes same like as header file in c header file is a collection of functions in c
  • 13. import packagename; e.g. import java.io.*; -->this statement allow us to use all classes present in java.io. import java.io.DataInputStream;-->we can use only one class in program from java.io package import is the keyword in java which is used to add the package in program
  • 14. create the object of DataInputStream class if we want to use the class and its member any where for that we need to object Synatx DataInputStream objectname=new DataInputStream(System.in);
  • 16. use its readLine() method for input readLine() is the method of DataInputStream class which is used to accept the input from keyboard Use of readLine() method objectofdatainputstream.readLine()
  • 17. //P1 import java.io.*; public class DataFirst { public static void main(String x[])throws Exception { DataInputStream xyz=new DataInputStream(System.in); int num,sq; System.out.println("Enter the number");
  • 19. //P2 import java.io.*; public class Student { public static void main(String x[])throws Exception { DataInputStream input=new DataInputStream(System.in); int number; String name; float marks; System.out.println("enter the name of student"); name=input.readLine(); System.out.println("Enter the id of student"); number=Integer.parseInt(input.readLine()); System.out.println("Enter the marks of student"); }
  • 20. marks=Float.valueOf(input.readLine()).floatValue(); System.out.println("Name of student "+name); System.out.println("Id of student is "+number); System.out.println("Marks of student is "+marks); }
  • 21. Problem with readLine() method Need to convert for every input other than string for that java provide the another optional class for input to us Scanner .
  • 22. Scanner is a class same like as DataInputStram Scanner is a member of java.util package  add the util package in programme import java.util.*; create the object of Scanner class Scanner object=new Scanner(System.in); e.g Scanner input=new Scanner(System.in); Use its following method for input
  • 23. nextInt() --> for integer input nextFloat() ---> for float input nextDouble() --> for double input nextByte() --> for byte input nextLine() ----> for string input nextShort() -->short integer input nextLong() ---> for long integer input
  • 24. import java.util.*; public class ScannerApp { public static void main(String x[]) { Scanner xyz=new Scanner(System.in); int id; float marks; String name; System.out.println("Enter the name "); name=xyz.nextLine(); System.out.println("enter the id "); id=xyz.nextInt(); System.out.println("enter the marks ");
  • 25. marks=xyz.nextFloat(); System.out.println("Name is "+name); System.out.println("Id is "+id); System.out.println("Marks is "+marks); } }