SlideShare a Scribd company logo
AI Programming
with JAVA
By:Virat Andodariya
M.S.University
1
How Artificial Intelligence Programmed?
Java Basics
Graph coloring Problem
Uniform Cost Search
Contents
2
How Artificial Intelligence Programmed?
C++
C#
Java
Lisp
Python
3
Java Basics
• The Java Virtual Machine
• Applications & Applets
• Classes & Objects
• Start up Java
• Variables & Assignments
• Strings & Characters
• Arithmetic Operators & Expressions
• Comments
• Keywords
• Creating and Compiling Programs
• Modifiers
4
Bytecodes and the Java Virtual Machine
5
Java Program
• Java Application Program
– Application
• Program written in general programming language
– Applet
• Program running in Web Browser Environment
• Can be viewed by appletviewer or Web browser with
JVM
6
Classes and Objects
• Object
– Memory Space to Define State and Operation
– Instance of Class
• Class
– A class is a template or blueprint for objects. To program in
Java, you must understand classes and be able to write and
use them.
– Template of Creating Object
7
The Java Class Libraries
• java.applet : Applet related
• java.awt : Abstract Window Toolkit
• java.awt.event : Event process from awt component
• java.awt.image : Image processing
• java.beans : JavaBeans Component
• java.io : File or Network I/O Support
• java.lang : Java Language Support
• java.net : Network related functions
• java.util : Utility function
8
Start a Java Application
9
Variables and Assignments
• Types
– char 16bits Unicode character data
– boolean Boolean Variable
– byte 8 bits signed integer
– short 16 bits signed integer
– int 32 bits signed integer
– long 64 bits signed integer
– float 32 bits signed floating point number
– double 64 bits signed floating point number
10
Variables and Assignments
• String : sequence of character
String s = “Enter an integer value: ” ;
• Concatenation Operator ‘+’
String s = “Lincoln said: ” + “” Four score and seven years
ago”” ;
Result :
Lincoln said: “Four score and seven years ago”
11
Comments
• Single Line Comment
– int i = 10 ; // i is counter
• Multiple Line Comment
/*
Some comments
*/
• Documentation Comment
/**
Documentation Comment
*/
12
Java Keywords
• 50 Java Keywords
abstract double int super
boolean else interface s witch
break extends long synchronized
byte final native this
case finally new throw
catch float package throws
char for private transient*
class goto* protected try
const* if public void
continue implements return volatile
default import short while
do instanceof static strictfp
assert (New in 1.5) enum (New in 1.5)
13
Control Statement
• A statement represents an action or a sequence of actions.
To change the execution order of program
• As the method of controlling the execution order
– Conditional Statement : if St., switch St.
– Repeat Statement : for St., while St., do-while St.
– Branch Statement : break St., continue St., return St.
14
For Statement
 Repeat the sequence of statement as many as defined.
 Form of for statement
for ( <expr. 1> ; < expr. 2> ; < expr. 3>)
<statement>
 <expr. 1> : initialize the control variable
 <expr. 2> : check the control variable
 <expr. 3> : modify the control variable
s = 0;
for (i=1; i<=N; ++i) // sum from 1 to N : i increment
s += i;
15
Break Statement
• To move control to the out of the block
• From of break statement
break [label] ;
16
Source Code
Create/Modify Source Code
Compile Source Code
i.e. javac Welcome.java
Bytecode
Run Byteode
i.e. java Welcome
Result
If compilation errors
If runtime errors or incorrect result
17
Modifiers
Java uses certain reserved words called modifiers that specify
the properties of the data, methods, and classes and how
they can be used.
Examples of modifiers are public and static. Other modifiers are
private, final, abstract, and protected. A public datum,
method, or class can be accessed by other programs. A
private datum or method cannot be accessed by other
programs.
18
Graph coloring Problem
Graph In Matrix
19
Graph Coloring
20
21
22
23
24
Result
25
UniformCostSearch
26
27
28
29
30
31
32
33
34
35
36
37
38
References
• Java™ 2:The Complete Reference,Fifth Edition
Herbert Schildt
• JDK Developer Kit
• JGRASP (CSD) Compiler
39
Thank you
40

More Related Content

What's hot

Project presentation
Project presentationProject presentation
Project presentationTrung Dang
 
Differences between method overloading and method overriding
Differences between method overloading and method overridingDifferences between method overloading and method overriding
Differences between method overloading and method overriding
Pinky Anaya
 
Java 8 new features
Java 8 new featuresJava 8 new features
Java 8 new features
Aniket Thakur
 
Java8 features
Java8 featuresJava8 features
Java8 features
Minal Maniar
 
Introduction to objects and inputoutput
Introduction to objects and inputoutput Introduction to objects and inputoutput
Introduction to objects and inputoutput
Ahmad Idrees
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
SadhanaParameswaran
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slides
rfojdar
 
Function procedure c6 c7
Function procedure  c6 c7Function procedure  c6 c7
Function procedure c6 c7
Omar Al-Sabek
 
Actors model in gpars
Actors model in gparsActors model in gpars
Actors model in gpars
NexThoughts Technologies
 
Pi j1.2 variable-assignment
Pi j1.2 variable-assignmentPi j1.2 variable-assignment
Pi j1.2 variable-assignment
mcollison
 
Intro To Scala
Intro To ScalaIntro To Scala
Intro To Scala
chambeda
 
Learn To Code: Introduction to c
Learn To Code: Introduction to cLearn To Code: Introduction to c
Learn To Code: Introduction to c
SadhanaParameswaran
 
Inheritance
InheritanceInheritance
Inheritance
Jaya Kumari
 
Refactoring - An Introduction
Refactoring - An IntroductionRefactoring - An Introduction
Refactoring - An Introduction
Giorgio Vespucci
 
Method overloading and constructor overloading in java
Method overloading and constructor overloading in javaMethod overloading and constructor overloading in java
Method overloading and constructor overloading in java
baabtra.com - No. 1 supplier of quality freshers
 
Java chapter 2
Java chapter 2Java chapter 2
Java chapter 2
Abdii Rashid
 
Command line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorialCommand line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorial
Kuntal Bhowmick
 
java 8 new features
java 8 new features java 8 new features
java 8 new features
Rohit Verma
 

What's hot (18)

Project presentation
Project presentationProject presentation
Project presentation
 
Differences between method overloading and method overriding
Differences between method overloading and method overridingDifferences between method overloading and method overriding
Differences between method overloading and method overriding
 
Java 8 new features
Java 8 new featuresJava 8 new features
Java 8 new features
 
Java8 features
Java8 featuresJava8 features
Java8 features
 
Introduction to objects and inputoutput
Introduction to objects and inputoutput Introduction to objects and inputoutput
Introduction to objects and inputoutput
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slides
 
Function procedure c6 c7
Function procedure  c6 c7Function procedure  c6 c7
Function procedure c6 c7
 
Actors model in gpars
Actors model in gparsActors model in gpars
Actors model in gpars
 
Pi j1.2 variable-assignment
Pi j1.2 variable-assignmentPi j1.2 variable-assignment
Pi j1.2 variable-assignment
 
Intro To Scala
Intro To ScalaIntro To Scala
Intro To Scala
 
Learn To Code: Introduction to c
Learn To Code: Introduction to cLearn To Code: Introduction to c
Learn To Code: Introduction to c
 
Inheritance
InheritanceInheritance
Inheritance
 
Refactoring - An Introduction
Refactoring - An IntroductionRefactoring - An Introduction
Refactoring - An Introduction
 
Method overloading and constructor overloading in java
Method overloading and constructor overloading in javaMethod overloading and constructor overloading in java
Method overloading and constructor overloading in java
 
Java chapter 2
Java chapter 2Java chapter 2
Java chapter 2
 
Command line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorialCommand line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorial
 
java 8 new features
java 8 new features java 8 new features
java 8 new features
 

Similar to java in Aartificial intelligent by virat andodariya

Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_reviewEdureka!
 
Introduction to java 101
Introduction to java 101Introduction to java 101
Introduction to java 101
kankemwa Ishaku
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
sunila tharagaturi
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
VAIBHAVKADAGANCHI
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basics
LovelitJose
 
Java 101
Java 101Java 101
Java 101
Manuela Grindei
 
Java class 1
Java class 1Java class 1
Java class 1Edureka!
 
2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)
Shoaib Ghachi
 
JavaScript Interview Questions Part - 1.pdf
JavaScript Interview Questions Part - 1.pdfJavaScript Interview Questions Part - 1.pdf
JavaScript Interview Questions Part - 1.pdf
katarichallenge
 
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
AssignmentjsnsnshshusjdnsnshhzudjdndndjdAssignmentjsnsnshshusjdnsnshhzudjdndndjd
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
tusharjain613841
 
Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and import
iamluqman0403
 
Intro to javascript (6:19)
Intro to javascript (6:19)Intro to javascript (6:19)
Intro to javascript (6:19)
Thinkful
 
Technical trainning.pptx
Technical trainning.pptxTechnical trainning.pptx
Technical trainning.pptx
SanuSan3
 
Thinkful - Intro to JavaScript
Thinkful - Intro to JavaScriptThinkful - Intro to JavaScript
Thinkful - Intro to JavaScript
TJ Stalcup
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for selenium
apoorvams
 
JavaScript, VBScript, AJAX, CGI
JavaScript, VBScript, AJAX, CGIJavaScript, VBScript, AJAX, CGI
JavaScript, VBScript, AJAX, CGI
Aashish Jain
 
Programming Language
Programming  LanguageProgramming  Language
Programming LanguageAdeel Hamid
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.
Tarunsingh198
 

Similar to java in Aartificial intelligent by virat andodariya (20)

Unit 1
Unit 1Unit 1
Unit 1
 
Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_review
 
Introduction to java 101
Introduction to java 101Introduction to java 101
Introduction to java 101
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basics
 
Java 101
Java 101Java 101
Java 101
 
Java class 1
Java class 1Java class 1
Java class 1
 
2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)
 
JavaScript Interview Questions Part - 1.pdf
JavaScript Interview Questions Part - 1.pdfJavaScript Interview Questions Part - 1.pdf
JavaScript Interview Questions Part - 1.pdf
 
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
AssignmentjsnsnshshusjdnsnshhzudjdndndjdAssignmentjsnsnshshusjdnsnshhzudjdndndjd
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
 
Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and import
 
Intro to javascript (6:19)
Intro to javascript (6:19)Intro to javascript (6:19)
Intro to javascript (6:19)
 
Java
Java Java
Java
 
Technical trainning.pptx
Technical trainning.pptxTechnical trainning.pptx
Technical trainning.pptx
 
Thinkful - Intro to JavaScript
Thinkful - Intro to JavaScriptThinkful - Intro to JavaScript
Thinkful - Intro to JavaScript
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for selenium
 
JavaScript, VBScript, AJAX, CGI
JavaScript, VBScript, AJAX, CGIJavaScript, VBScript, AJAX, CGI
JavaScript, VBScript, AJAX, CGI
 
Programming Language
Programming  LanguageProgramming  Language
Programming Language
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.
 

Recently uploaded

LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
ssuser9bd3ba
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
MuhammadTufail242431
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 

Recently uploaded (20)

LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 

java in Aartificial intelligent by virat andodariya

  • 1. AI Programming with JAVA By:Virat Andodariya M.S.University 1
  • 2. How Artificial Intelligence Programmed? Java Basics Graph coloring Problem Uniform Cost Search Contents 2
  • 3. How Artificial Intelligence Programmed? C++ C# Java Lisp Python 3
  • 4. Java Basics • The Java Virtual Machine • Applications & Applets • Classes & Objects • Start up Java • Variables & Assignments • Strings & Characters • Arithmetic Operators & Expressions • Comments • Keywords • Creating and Compiling Programs • Modifiers 4
  • 5. Bytecodes and the Java Virtual Machine 5
  • 6. Java Program • Java Application Program – Application • Program written in general programming language – Applet • Program running in Web Browser Environment • Can be viewed by appletviewer or Web browser with JVM 6
  • 7. Classes and Objects • Object – Memory Space to Define State and Operation – Instance of Class • Class – A class is a template or blueprint for objects. To program in Java, you must understand classes and be able to write and use them. – Template of Creating Object 7
  • 8. The Java Class Libraries • java.applet : Applet related • java.awt : Abstract Window Toolkit • java.awt.event : Event process from awt component • java.awt.image : Image processing • java.beans : JavaBeans Component • java.io : File or Network I/O Support • java.lang : Java Language Support • java.net : Network related functions • java.util : Utility function 8
  • 9. Start a Java Application 9
  • 10. Variables and Assignments • Types – char 16bits Unicode character data – boolean Boolean Variable – byte 8 bits signed integer – short 16 bits signed integer – int 32 bits signed integer – long 64 bits signed integer – float 32 bits signed floating point number – double 64 bits signed floating point number 10
  • 11. Variables and Assignments • String : sequence of character String s = “Enter an integer value: ” ; • Concatenation Operator ‘+’ String s = “Lincoln said: ” + “” Four score and seven years ago”” ; Result : Lincoln said: “Four score and seven years ago” 11
  • 12. Comments • Single Line Comment – int i = 10 ; // i is counter • Multiple Line Comment /* Some comments */ • Documentation Comment /** Documentation Comment */ 12
  • 13. Java Keywords • 50 Java Keywords abstract double int super boolean else interface s witch break extends long synchronized byte final native this case finally new throw catch float package throws char for private transient* class goto* protected try const* if public void continue implements return volatile default import short while do instanceof static strictfp assert (New in 1.5) enum (New in 1.5) 13
  • 14. Control Statement • A statement represents an action or a sequence of actions. To change the execution order of program • As the method of controlling the execution order – Conditional Statement : if St., switch St. – Repeat Statement : for St., while St., do-while St. – Branch Statement : break St., continue St., return St. 14
  • 15. For Statement  Repeat the sequence of statement as many as defined.  Form of for statement for ( <expr. 1> ; < expr. 2> ; < expr. 3>) <statement>  <expr. 1> : initialize the control variable  <expr. 2> : check the control variable  <expr. 3> : modify the control variable s = 0; for (i=1; i<=N; ++i) // sum from 1 to N : i increment s += i; 15
  • 16. Break Statement • To move control to the out of the block • From of break statement break [label] ; 16
  • 17. Source Code Create/Modify Source Code Compile Source Code i.e. javac Welcome.java Bytecode Run Byteode i.e. java Welcome Result If compilation errors If runtime errors or incorrect result 17
  • 18. Modifiers Java uses certain reserved words called modifiers that specify the properties of the data, methods, and classes and how they can be used. Examples of modifiers are public and static. Other modifiers are private, final, abstract, and protected. A public datum, method, or class can be accessed by other programs. A private datum or method cannot be accessed by other programs. 18
  • 21. 21
  • 22. 22
  • 23. 23
  • 24. 24
  • 27. 27
  • 28. 28
  • 29. 29
  • 30. 30
  • 31. 31
  • 32. 32
  • 33. 33
  • 34. 34
  • 35. 35
  • 36. 36
  • 37. 37
  • 38. 38
  • 39. References • Java™ 2:The Complete Reference,Fifth Edition Herbert Schildt • JDK Developer Kit • JGRASP (CSD) Compiler 39