SlideShare a Scribd company logo
Compiling the First Java Program
•Printing Hello World On Screen
•Understanding the keywords
•Understanding the Syntax of program
•How to compile a java program
•How to execute a java Program
•What is camel case syntax.
4/10/2019 1Jamsher Bhanbhro(F16CS11)
Hello World!
• public class HelloWorld{
public static void main (String args[]){
System.out.println(“Hello World!”);
}
}
4/10/2019 Jamsher Bhanbhro(F16CS11) 2
Understanding the syntax
• Here public is the access modifier which tells
the accesses of our program/class i.e where our
class can be called and where it can’t.
• Public means we can call our class throughout
the program it can run any where it is public.
• Further we will discuss in the access modifier
lecture.
4/10/2019 Jamsher Bhanbhro(F16CS11) 3
Cont…
• Class is the keyword which makes our
program’s class.
• Class is the collection of the object’s properties
and behavior.
• HelloWorld is the name of the calss.
• Curly braces are the body of the program.
4/10/2019 Jamsher Bhanbhro(F16CS11) 4
Cont…
• public static : static is the reference variable or
the keyword which is used to call a function or
a program without creating an object.
• We have used static keyword with main
method because we may call it several times
so we want to call it directly without creating
it’s object many times.
• Void: this is the type the method it tells
methods will return some value.
4/10/2019 Jamsher Bhanbhro(F16CS11) 5
Cont…
• main: it is name of the method.
• String args[]: it is the array which tells that main method will take
arguments.
• We will further discus string args in the upcoming lectures.
• System: It is the class which is predefined in which there are built-in
functions for showing outputs.
• .out: it is an object or the reference variables which use the inner
functions of the System Class like printing some ting etc.
• println: print on new line.
• the square braces tells the args of the method.
• In the double square text is written which will show as it is on the
screen. In the above case there is Hello World
• And the last bracket use to end the program.
4/10/2019 Jamsher Bhanbhro(F16CS11) 6
Syntax
The above program uses the followings…
1. Classes
2. Objects
3. Keywords
4. Identifiers
5. Methods/Functions
6. Braces
4/10/2019 Jamsher Bhanbhro(F16CS11) 7
How to compile the java program
• After writing the code save it as Classname.java
• Name of the file and the class should be the same.
• If the path of your machine is than open command window and type javac and the
name of your program.java
• javac is the java compiler.
• After typing this in cmd press enter if there will be error of path set or errors in
your program than that will be shown here if not than .class file will be developed
in the directory where your program is saved.
• If .class file is formed it means your code is compiled successfully.
4/10/2019 Jamsher Bhanbhro(F16CS11) 8
How to execute a java program
• If there no any error occur during the compile
time it means your path is set and your code is
also right.
• So now for the execution or checking the
output functionality of our program we have to
write java class-name i.e java HelloWorld
4/10/2019 Jamsher Bhanbhro(F16CS11) 9
What is Camel Case in java
• Camel case stands that the first latter of the
each class should be written in the capital
letter.
• This is more useful because we will easy
understand that which is class when there is
large code in our program.
• In the above case there are three classes
• i- HelloWorld ii-System iii-String
4/10/2019 Jamsher Bhanbhro(F16CS11) 10

More Related Content

What's hot

Bt0074 oops with java2
Bt0074 oops with java2Bt0074 oops with java2
Bt0074 oops with java2
Techglyphs
 
Java8 features
Java8 featuresJava8 features
Java8 features
Minal Maniar
 
Lecture 3 java basics
Lecture 3 java basicsLecture 3 java basics
Lecture 3 java basicsthe_wumberlog
 
Java se 8 language enhancements & features
Java se 8   language enhancements & featuresJava se 8   language enhancements & features
Java se 8 language enhancements & features
Juarez Junior
 
GA Sample Teach: Intro to JS Functions
GA Sample Teach: Intro to JS FunctionsGA Sample Teach: Intro to JS Functions
GA Sample Teach: Intro to JS Functions
Thinkful
 
Error handling and debugging in vb
Error handling and debugging in vbError handling and debugging in vb
Error handling and debugging in vb
Salim M
 
Examples c#
Examples c#Examples c#
Examples c#
bhaskard8
 
Exception handling in ASP .NET
Exception handling in ASP .NETException handling in ASP .NET
Exception handling in ASP .NET
baabtra.com - No. 1 supplier of quality freshers
 
Java ce241
Java ce241Java ce241
Java ce241
Minal Maniar
 
Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz
SAurabh PRajapati
 
Architecture diagram of jvm
Architecture diagram of jvmArchitecture diagram of jvm
Architecture diagram of jvm
home
 
Debugging in .Net
Debugging in .NetDebugging in .Net
Debugging in .Net
Muhammad Amir
 
Bc0051 – system software
Bc0051 – system softwareBc0051 – system software
Bc0051 – system softwaresmumbahelp
 
7 programming-using-java decision-making220102011
7 programming-using-java decision-making2201020117 programming-using-java decision-making220102011
7 programming-using-java decision-making220102011
Mahmoud Alfarra
 
Java features
Java featuresJava features
Java features
Prashant Gajendra
 

What's hot (20)

Bt0074 oops with java2
Bt0074 oops with java2Bt0074 oops with java2
Bt0074 oops with java2
 
Java8 features
Java8 featuresJava8 features
Java8 features
 
Java basics training 1
Java basics training 1Java basics training 1
Java basics training 1
 
Lecture 3 java basics
Lecture 3 java basicsLecture 3 java basics
Lecture 3 java basics
 
Java se 8 language enhancements & features
Java se 8   language enhancements & featuresJava se 8   language enhancements & features
Java se 8 language enhancements & features
 
GA Sample Teach: Intro to JS Functions
GA Sample Teach: Intro to JS FunctionsGA Sample Teach: Intro to JS Functions
GA Sample Teach: Intro to JS Functions
 
Java
JavaJava
Java
 
Quiz1solt (2)
Quiz1solt (2)Quiz1solt (2)
Quiz1solt (2)
 
Error handling and debugging in vb
Error handling and debugging in vbError handling and debugging in vb
Error handling and debugging in vb
 
Examples c#
Examples c#Examples c#
Examples c#
 
3. jvm
3. jvm3. jvm
3. jvm
 
Exception handling in ASP .NET
Exception handling in ASP .NETException handling in ASP .NET
Exception handling in ASP .NET
 
JVM
JVMJVM
JVM
 
Java ce241
Java ce241Java ce241
Java ce241
 
Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz
 
Architecture diagram of jvm
Architecture diagram of jvmArchitecture diagram of jvm
Architecture diagram of jvm
 
Debugging in .Net
Debugging in .NetDebugging in .Net
Debugging in .Net
 
Bc0051 – system software
Bc0051 – system softwareBc0051 – system software
Bc0051 – system software
 
7 programming-using-java decision-making220102011
7 programming-using-java decision-making2201020117 programming-using-java decision-making220102011
7 programming-using-java decision-making220102011
 
Java features
Java featuresJava features
Java features
 

Similar to Lect4

Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Intro to programing with java-lecture 1
Intro to programing with java-lecture 1
Mohamed Essam
 
Basics of java 1
Basics of java 1Basics of java 1
Basics of java 1
Vijay Kankane
 
lecture 6
 lecture 6 lecture 6
lecture 6
umardanjumamaiwada
 
Introduction to computer science
Introduction to computer scienceIntroduction to computer science
Introduction to computer science
umardanjumamaiwada
 
Java lab1 manual
Java lab1 manualJava lab1 manual
Java lab1 manual
nahalomar
 
01-ch01-1-println.ppt java introduction one
01-ch01-1-println.ppt java introduction one01-ch01-1-println.ppt java introduction one
01-ch01-1-println.ppt java introduction one
ssuser656672
 
Intro Java Rev010
Intro Java Rev010Intro Java Rev010
Intro Java Rev010Rich Helton
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for Mainframers
Rich Helton
 
Java
JavaJava
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using ReflectionGanesh Samarthyam
 
Unit of competency
Unit of competencyUnit of competency
Unit of competency
loidasacueza
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting Started
Martin Chapman
 
Concurrency Programming in Java - 02 - Essentials of Java Part 1
Concurrency Programming in Java - 02 - Essentials of Java Part 1Concurrency Programming in Java - 02 - Essentials of Java Part 1
Concurrency Programming in Java - 02 - Essentials of Java Part 1
Sachintha Gunasena
 
Java introduction
Java introductionJava introduction
Java introduction
logeswarisaravanan
 
Selenium web driver | java
Selenium web driver | javaSelenium web driver | java
Selenium web driver | java
Rajesh Kumar
 
Java Programming Fundamentals
Java Programming Fundamentals Java Programming Fundamentals
Java Programming Fundamentals
Dr. Rosemarie Sibbaluca-Guirre
 
Unit2 java
Unit2 javaUnit2 java
Unit2 javamrecedu
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1sotlsoc
 

Similar to Lect4 (20)

Intro to programing with java-lecture 1
Intro to programing with java-lecture 1Intro to programing with java-lecture 1
Intro to programing with java-lecture 1
 
Basics of java 1
Basics of java 1Basics of java 1
Basics of java 1
 
lecture 6
 lecture 6 lecture 6
lecture 6
 
Introduction to computer science
Introduction to computer scienceIntroduction to computer science
Introduction to computer science
 
Java lab1 manual
Java lab1 manualJava lab1 manual
Java lab1 manual
 
01-ch01-1-println.ppt java introduction one
01-ch01-1-println.ppt java introduction one01-ch01-1-println.ppt java introduction one
01-ch01-1-println.ppt java introduction one
 
Intro Java Rev010
Intro Java Rev010Intro Java Rev010
Intro Java Rev010
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for Mainframers
 
Java
JavaJava
Java
 
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using Reflection
 
Unit of competency
Unit of competencyUnit of competency
Unit of competency
 
Programming in Java: Getting Started
Programming in Java: Getting StartedProgramming in Java: Getting Started
Programming in Java: Getting Started
 
01slide
01slide01slide
01slide
 
01slide
01slide01slide
01slide
 
Concurrency Programming in Java - 02 - Essentials of Java Part 1
Concurrency Programming in Java - 02 - Essentials of Java Part 1Concurrency Programming in Java - 02 - Essentials of Java Part 1
Concurrency Programming in Java - 02 - Essentials of Java Part 1
 
Java introduction
Java introductionJava introduction
Java introduction
 
Selenium web driver | java
Selenium web driver | javaSelenium web driver | java
Selenium web driver | java
 
Java Programming Fundamentals
Java Programming Fundamentals Java Programming Fundamentals
Java Programming Fundamentals
 
Unit2 java
Unit2 javaUnit2 java
Unit2 java
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
 

More from Jamsher bhanbhro

Abstraction in Java: Abstract class and Interfaces
Abstraction in  Java: Abstract class and InterfacesAbstraction in  Java: Abstract class and Interfaces
Abstraction in Java: Abstract class and Interfaces
Jamsher bhanbhro
 
Method, Constructor, Method Overloading, Method Overriding, Inheritance In Java
Method, Constructor, Method Overloading, Method Overriding, Inheritance In  JavaMethod, Constructor, Method Overloading, Method Overriding, Inheritance In  Java
Method, Constructor, Method Overloading, Method Overriding, Inheritance In Java
Jamsher bhanbhro
 
Regular Expressions in Java.
Regular Expressions in Java.Regular Expressions in Java.
Regular Expressions in Java.
Jamsher bhanbhro
 
Java Arrays and DateTime Functions
Java Arrays and DateTime FunctionsJava Arrays and DateTime Functions
Java Arrays and DateTime Functions
Jamsher bhanbhro
 
Lect10
Lect10Lect10
Lect9
Lect9Lect9
Lect8
Lect8Lect8
Lect7
Lect7Lect7
Lect6
Lect6Lect6
Lect5
Lect5Lect5
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
Jamsher bhanbhro
 
Caap presentation by me
Caap presentation by meCaap presentation by me
Caap presentation by me
Jamsher bhanbhro
 
Introduction to parts of Computer(Computer Fundamentals)
Introduction to parts of Computer(Computer Fundamentals)Introduction to parts of Computer(Computer Fundamentals)
Introduction to parts of Computer(Computer Fundamentals)
Jamsher bhanbhro
 

More from Jamsher bhanbhro (13)

Abstraction in Java: Abstract class and Interfaces
Abstraction in  Java: Abstract class and InterfacesAbstraction in  Java: Abstract class and Interfaces
Abstraction in Java: Abstract class and Interfaces
 
Method, Constructor, Method Overloading, Method Overriding, Inheritance In Java
Method, Constructor, Method Overloading, Method Overriding, Inheritance In  JavaMethod, Constructor, Method Overloading, Method Overriding, Inheritance In  Java
Method, Constructor, Method Overloading, Method Overriding, Inheritance In Java
 
Regular Expressions in Java.
Regular Expressions in Java.Regular Expressions in Java.
Regular Expressions in Java.
 
Java Arrays and DateTime Functions
Java Arrays and DateTime FunctionsJava Arrays and DateTime Functions
Java Arrays and DateTime Functions
 
Lect10
Lect10Lect10
Lect10
 
Lect9
Lect9Lect9
Lect9
 
Lect8
Lect8Lect8
Lect8
 
Lect7
Lect7Lect7
Lect7
 
Lect6
Lect6Lect6
Lect6
 
Lect5
Lect5Lect5
Lect5
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Caap presentation by me
Caap presentation by meCaap presentation by me
Caap presentation by me
 
Introduction to parts of Computer(Computer Fundamentals)
Introduction to parts of Computer(Computer Fundamentals)Introduction to parts of Computer(Computer Fundamentals)
Introduction to parts of Computer(Computer Fundamentals)
 

Recently uploaded

Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
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
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
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
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 

Recently uploaded (20)

Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
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
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
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
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 

Lect4

  • 1. Compiling the First Java Program •Printing Hello World On Screen •Understanding the keywords •Understanding the Syntax of program •How to compile a java program •How to execute a java Program •What is camel case syntax. 4/10/2019 1Jamsher Bhanbhro(F16CS11)
  • 2. Hello World! • public class HelloWorld{ public static void main (String args[]){ System.out.println(“Hello World!”); } } 4/10/2019 Jamsher Bhanbhro(F16CS11) 2
  • 3. Understanding the syntax • Here public is the access modifier which tells the accesses of our program/class i.e where our class can be called and where it can’t. • Public means we can call our class throughout the program it can run any where it is public. • Further we will discuss in the access modifier lecture. 4/10/2019 Jamsher Bhanbhro(F16CS11) 3
  • 4. Cont… • Class is the keyword which makes our program’s class. • Class is the collection of the object’s properties and behavior. • HelloWorld is the name of the calss. • Curly braces are the body of the program. 4/10/2019 Jamsher Bhanbhro(F16CS11) 4
  • 5. Cont… • public static : static is the reference variable or the keyword which is used to call a function or a program without creating an object. • We have used static keyword with main method because we may call it several times so we want to call it directly without creating it’s object many times. • Void: this is the type the method it tells methods will return some value. 4/10/2019 Jamsher Bhanbhro(F16CS11) 5
  • 6. Cont… • main: it is name of the method. • String args[]: it is the array which tells that main method will take arguments. • We will further discus string args in the upcoming lectures. • System: It is the class which is predefined in which there are built-in functions for showing outputs. • .out: it is an object or the reference variables which use the inner functions of the System Class like printing some ting etc. • println: print on new line. • the square braces tells the args of the method. • In the double square text is written which will show as it is on the screen. In the above case there is Hello World • And the last bracket use to end the program. 4/10/2019 Jamsher Bhanbhro(F16CS11) 6
  • 7. Syntax The above program uses the followings… 1. Classes 2. Objects 3. Keywords 4. Identifiers 5. Methods/Functions 6. Braces 4/10/2019 Jamsher Bhanbhro(F16CS11) 7
  • 8. How to compile the java program • After writing the code save it as Classname.java • Name of the file and the class should be the same. • If the path of your machine is than open command window and type javac and the name of your program.java • javac is the java compiler. • After typing this in cmd press enter if there will be error of path set or errors in your program than that will be shown here if not than .class file will be developed in the directory where your program is saved. • If .class file is formed it means your code is compiled successfully. 4/10/2019 Jamsher Bhanbhro(F16CS11) 8
  • 9. How to execute a java program • If there no any error occur during the compile time it means your path is set and your code is also right. • So now for the execution or checking the output functionality of our program we have to write java class-name i.e java HelloWorld 4/10/2019 Jamsher Bhanbhro(F16CS11) 9
  • 10. What is Camel Case in java • Camel case stands that the first latter of the each class should be written in the capital letter. • This is more useful because we will easy understand that which is class when there is large code in our program. • In the above case there are three classes • i- HelloWorld ii-System iii-String 4/10/2019 Jamsher Bhanbhro(F16CS11) 10