Africa Information
Technology Initiative
Lecture 1:
Introduction to Java
AITI 2009
http://aiti.mit.eduAfrica Information Technology Initiative © 2009
Agenda
• What makes Java special?
• Advantages and disadvantages to using
Java.
• Methodology for developing applications.
2
http://aiti.mit.eduAfrica Information Technology Initiative © 2009
Compiler
…
a = b + c
…
…
ld $r1, a
ld $r2, b
add $r3, $r1, $r2
st a, $r3
…
Compiler
High-Level
Code
Machine Code
• A program that translates a programming
language into machine code is called a compiler
• Typically, we must have a compiler for each
operating system/machine combination (platform)
http://aiti.mit.eduAfrica Information Technology Initiative © 2009
Compiling Computer Programs
• Because different platforms require different machine
code, you must compile programs separately for
each platform, then execute the machine code.
program
compiler
compiler
compiler
Win
Mac
Unix
machine codemachine code
machine code
http://aiti.mit.eduAfrica Information Technology Initiative © 2009
The Java Compiler is Different!
• The Java compiler produces an
intermediate format called bytecode.
• Bytecode is not machine code for any
real computer.
• Bytecode is machine code for a model
computer.
– This model computer is called the Java
Virtual Machine.
Java Program
compiler
Java Bytecode
http://aiti.mit.eduAfrica Information Technology Initiative © 2009
Java Interpreter
• A Java Interpreter is required to execute the
bytecode on a real computer.
• A Java Interpreter converts the bytecode into
machine code.
– As the program executes
– Simulate the execution of the Java Virtual Machine on
the real computer
• You can run bytecode on any computer that has
a Java Interpreter (JRE) installed!
– Only have to compile once
– Can distribute the same bytecode to everyone
http://aiti.mit.eduAfrica Information Technology Initiative © 2009
The Java Approach
Java Program
compiler
Java bytecode
Win
Mac
Unix
Interpreter
Interpreter
Interpreter
http://aiti.mit.eduAfrica Information Technology Initiative © 2009
Advantages of Using Java
• Once a Java program is compiled you can run the
bytecode on any device with a Java Interpreter.
– Because you do not have to recompile the program for each
machine, Java is device independent.
• Java is safe. The Java language and compiler restrict
certain operations to prevent errors.
– Would you want an application to have total control of your
phone?
• Make calls, send SMS messages?
• Java standardizes many useful structures and
operations such as lists, managing network connections,
and providing graphical user interfaces
http://aiti.mit.eduAfrica Information Technology Initiative © 2009
Disadvantages of Using Java
• Running bytecode through an interpreter is not
as fast as running machine code
– But this disadvantage is slowly disappearing
• Using device specific features (e.g., bluetooth) is
difficult sometimes because Java is device-
independent.
• In order to run a Java program on multiple
devices, each must have a Java Interpreter
– Ex: most Nokia phones come with Java Interpreter
http://aiti.mit.eduAfrica Information Technology Initiative © 2009
Programming Methodology
1. Specify and analyze the problem
• Remove ambiguity
• Decide on inputs/outputs and algorithms
1. Design the program solution
• Organize problem into smaller pieces
• Identify existing code to reuse!
1. Implementation (programming)
2. Test and verify implementation
3. Maintain and update program
http://aiti.mit.eduAfrica Information Technology Initiative © 2009
Writing Good Code
• A program that meets specification is not
necessarily good.
• Will you be able to make changes to it?
– Will you understand it after some time?
• Others might need to look at your code
– Can they understand it?
• Write your program so that is easy to
understand and extend!
– Spend extra time thinking about these issues.
http://aiti.mit.eduAfrica Information Technology Initiative © 2009
Example Code: Comments
/* The HelloWorld class prints “Hello,
World!” to the screen */
public class HelloWorld {
public static void main(String[] args) {
// Prints “Hello, World!”
System.out.println("Hello, World!");
// Exit the program
System.exit(0);
}
}
http://aiti.mit.eduAfrica Information Technology Initiative © 2009
Comments
• Comments are used to describe what your code
does as an aid for you or others reading your
code. The Java compiler ignores them.
• Comments are made using //, which comments
to the end of the line, or /* */, which
comments everything inside of it (including
multiple lines)
• Two example comments:
– /* The HelloWorld class prints “Hello, World!” to the
screen */
– // Prints “Hello, World!”
http://aiti.mit.eduAfrica Information Technology Initiative © 2009
Comments on Commenting
• You may collaborate on software projects
with people around the world who you’ll
never meet
• Should be able to figure out how code
works by reading comments alone
• Anything that is not self-evident needs a
comment
• 50% of your code might be comments
• Coding is easy, commenting is not

More Related Content

PDF
Introduction to Java Programming Language
PPTX
Java v/s .NET - Which is Better?
PPTX
Features of java unit 1
PPTX
Features of java
PPTX
Java ms harsha
PPT
J2ee strutswithhibernate-140121221332-phpapp01
PPTX
Java presentation
PPTX
Important features of java
Introduction to Java Programming Language
Java v/s .NET - Which is Better?
Features of java unit 1
Features of java
Java ms harsha
J2ee strutswithhibernate-140121221332-phpapp01
Java presentation
Important features of java

What's hot (20)

PPTX
Java Lecture 1
PPT
Java features
PPTX
Training on Core java | PPT Presentation | Shravan Sanidhya
PPTX
Core Java
 
PPTX
Java Programming (M&M)
PPSX
Industrial Training Report on Java Technology.
PDF
Java Programming Basics
PDF
Introduction to Java
PPTX
Java Intro
PPTX
Features of java 02
DOCX
Industrial Training report on java
PPTX
Java seminar
PPTX
A Comparison of .NET Framework vs. Java Virtual Machine
PPTX
C,c++,java,php,.net training institute in delhi, best training institute for ...
PPTX
Programming in Java
PDF
130700548484460000
PPT
Java Programming : introduction
PDF
Summer training report on java se6 technology
PPTX
Structure programming – Java Programming – Theory
Java Lecture 1
Java features
Training on Core java | PPT Presentation | Shravan Sanidhya
Core Java
 
Java Programming (M&M)
Industrial Training Report on Java Technology.
Java Programming Basics
Introduction to Java
Java Intro
Features of java 02
Industrial Training report on java
Java seminar
A Comparison of .NET Framework vs. Java Virtual Machine
C,c++,java,php,.net training institute in delhi, best training institute for ...
Programming in Java
130700548484460000
Java Programming : introduction
Summer training report on java se6 technology
Structure programming – Java Programming – Theory
Ad

Viewers also liked (20)

PDF
Ozis Pre
ODP
Griffon: Re-imaging Desktop Java Technology
PDF
Android - 04 - Internship project introduction
PPT
1 introduction to java technology
PPT
Chapter 1 introduction to java technology
PDF
Java 7 - State of the Enterprise
PDF
Introduction to java technology
PDF
Whitep paper on Emerging java and .net technology and critical trends
PPTX
1 java programming- introduction
PPT
1 Introduction To Java Technology
PPTX
Introduction to Java Programming
PDF
Java Technology Trends
PPT
Introduction to-programming
PPTX
Presentation On Android OS
PPTX
What is Android OS in ppt ?
PPTX
Android OS Presentation
PPT
Java basic
PPTX
My presentation on Android in my college
PPT
Core java slides
PPT
Android seminar-presentation
Ozis Pre
Griffon: Re-imaging Desktop Java Technology
Android - 04 - Internship project introduction
1 introduction to java technology
Chapter 1 introduction to java technology
Java 7 - State of the Enterprise
Introduction to java technology
Whitep paper on Emerging java and .net technology and critical trends
1 java programming- introduction
1 Introduction To Java Technology
Introduction to Java Programming
Java Technology Trends
Introduction to-programming
Presentation On Android OS
What is Android OS in ppt ?
Android OS Presentation
Java basic
My presentation on Android in my college
Core java slides
Android seminar-presentation
Ad

Similar to An introduction to java programming language forbeginners(java programming tutorials) (20)

PPTX
Lec 1-of-oop2
PPTX
OOP-JAVA-UNIT-1-PPT updated.pptx object oriented programming language using java
PPTX
intoduction to java
PPTX
Object Oriented concept-JAVA-Module-1-PPT.pptx
PPTX
JAVA - Summary Introduction to java .pptx
PPT
C# Fundamental
PPTX
Chapter-introduction about java programming
PPT
Java Chapter 2 Overview.ppt
PPT
Java Chapter 2 Overview.ppt
PPT
Java & J2EE Struts with Hibernate Framework
PPTX
Embedded programming Embedded programming (1).pptx
PPTX
1.INTRODUCTION TO JAVA.pptx bggwudufwydwuwguwuywuwudgjxbjasgu
PPTX
unit1.pptx
PPTX
Mobile Application Development class 001
PPT
CROSS PLATFORM APPLICATIONS DEVELOPMENT
PPTX
JAVA PROGRAMMING-Unit I - Final PPT.pptx
PPTX
Top 4 Cross Platform tools for Mobile App Development
PPTX
21 Network Programmability and Automation (1).pptx
PPTX
Top Programming Languages of 2020
PDF
1. Java Basic.pdf aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Lec 1-of-oop2
OOP-JAVA-UNIT-1-PPT updated.pptx object oriented programming language using java
intoduction to java
Object Oriented concept-JAVA-Module-1-PPT.pptx
JAVA - Summary Introduction to java .pptx
C# Fundamental
Chapter-introduction about java programming
Java Chapter 2 Overview.ppt
Java Chapter 2 Overview.ppt
Java & J2EE Struts with Hibernate Framework
Embedded programming Embedded programming (1).pptx
1.INTRODUCTION TO JAVA.pptx bggwudufwydwuwguwuywuwudgjxbjasgu
unit1.pptx
Mobile Application Development class 001
CROSS PLATFORM APPLICATIONS DEVELOPMENT
JAVA PROGRAMMING-Unit I - Final PPT.pptx
Top 4 Cross Platform tools for Mobile App Development
21 Network Programmability and Automation (1).pptx
Top Programming Languages of 2020
1. Java Basic.pdf aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

More from Daroko blog(www.professionalbloggertricks.com) (20)

DOCX
Small Business ideas you can start in Nigeria 2014(best Business ideas Nigeri...
DOCX
Agriculture business ideas for 2014(Business ideas Kenya,Business ideas Niger...
DOC
An Introduction to Project management(project management tutorials)
PDF
java arlow jdbc tutorial(java programming tutorials)
PDF
The java rogramming swing _tutorial for beinners(java programming language)
PDF
Java programming basics notes for beginners(java programming tutorials)
PDF
advanced java programming(java programming tutorials)
PDF
java swing tutorial for beginners(java programming tutorials)
PPT
fundamentals of Computer graphics(Computer graphics tutorials)
PPT
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
PPT
Computer Graphics display technologies(Computer graphics tutorials and tips)
PPT
Computer Graphics display technologies(Computer graphics tutorials)
PDF
Displays and color system in computer graphics(Computer graphics tutorials)
DOC
Data structures graphics library in computer graphics.
PPT
Csc406 lecture7 device independence and normalization in Computer graphics(Co...
PPT
lecture4 raster details in computer graphics(Computer graphics tutorials)
PPT
lecture3 color representation in computer graphics(Computer graphics tutorials)
PPT
lecture2 computer graphics graphics hardware(Computer graphics tutorials)
PPT
lecture1 introduction to computer graphics(Computer graphics tutorials)
Small Business ideas you can start in Nigeria 2014(best Business ideas Nigeri...
Agriculture business ideas for 2014(Business ideas Kenya,Business ideas Niger...
An Introduction to Project management(project management tutorials)
java arlow jdbc tutorial(java programming tutorials)
The java rogramming swing _tutorial for beinners(java programming language)
Java programming basics notes for beginners(java programming tutorials)
advanced java programming(java programming tutorials)
java swing tutorial for beginners(java programming tutorials)
fundamentals of Computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
Computer Graphics display technologies(Computer graphics tutorials and tips)
Computer Graphics display technologies(Computer graphics tutorials)
Displays and color system in computer graphics(Computer graphics tutorials)
Data structures graphics library in computer graphics.
Csc406 lecture7 device independence and normalization in Computer graphics(Co...
lecture4 raster details in computer graphics(Computer graphics tutorials)
lecture3 color representation in computer graphics(Computer graphics tutorials)
lecture2 computer graphics graphics hardware(Computer graphics tutorials)
lecture1 introduction to computer graphics(Computer graphics tutorials)

Recently uploaded (20)

PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
PDF
Uderstanding digital marketing and marketing stratergie for engaging the digi...
PDF
Empowerment Technology for Senior High School Guide
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PDF
Hazard Identification & Risk Assessment .pdf
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
Complications of Minimal Access-Surgery.pdf
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
Trump Administration's workforce development strategy
PDF
Weekly quiz Compilation Jan -July 25.pdf
B.Sc. DS Unit 2 Software Engineering.pptx
What if we spent less time fighting change, and more time building what’s rig...
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
Paper A Mock Exam 9_ Attempt review.pdf.
Environmental Education MCQ BD2EE - Share Source.pdf
Uderstanding digital marketing and marketing stratergie for engaging the digi...
Empowerment Technology for Senior High School Guide
Share_Module_2_Power_conflict_and_negotiation.pptx
Practical Manual AGRO-233 Principles and Practices of Natural Farming
Hazard Identification & Risk Assessment .pdf
History, Philosophy and sociology of education (1).pptx
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
Complications of Minimal Access-Surgery.pdf
LDMMIA Reiki Yoga Finals Review Spring Summer
Trump Administration's workforce development strategy
Weekly quiz Compilation Jan -July 25.pdf

An introduction to java programming language forbeginners(java programming tutorials)

  • 1. Africa Information Technology Initiative Lecture 1: Introduction to Java AITI 2009
  • 2. http://aiti.mit.eduAfrica Information Technology Initiative © 2009 Agenda • What makes Java special? • Advantages and disadvantages to using Java. • Methodology for developing applications. 2
  • 3. http://aiti.mit.eduAfrica Information Technology Initiative © 2009 Compiler … a = b + c … … ld $r1, a ld $r2, b add $r3, $r1, $r2 st a, $r3 … Compiler High-Level Code Machine Code • A program that translates a programming language into machine code is called a compiler • Typically, we must have a compiler for each operating system/machine combination (platform)
  • 4. http://aiti.mit.eduAfrica Information Technology Initiative © 2009 Compiling Computer Programs • Because different platforms require different machine code, you must compile programs separately for each platform, then execute the machine code. program compiler compiler compiler Win Mac Unix machine codemachine code machine code
  • 5. http://aiti.mit.eduAfrica Information Technology Initiative © 2009 The Java Compiler is Different! • The Java compiler produces an intermediate format called bytecode. • Bytecode is not machine code for any real computer. • Bytecode is machine code for a model computer. – This model computer is called the Java Virtual Machine. Java Program compiler Java Bytecode
  • 6. http://aiti.mit.eduAfrica Information Technology Initiative © 2009 Java Interpreter • A Java Interpreter is required to execute the bytecode on a real computer. • A Java Interpreter converts the bytecode into machine code. – As the program executes – Simulate the execution of the Java Virtual Machine on the real computer • You can run bytecode on any computer that has a Java Interpreter (JRE) installed! – Only have to compile once – Can distribute the same bytecode to everyone
  • 7. http://aiti.mit.eduAfrica Information Technology Initiative © 2009 The Java Approach Java Program compiler Java bytecode Win Mac Unix Interpreter Interpreter Interpreter
  • 8. http://aiti.mit.eduAfrica Information Technology Initiative © 2009 Advantages of Using Java • Once a Java program is compiled you can run the bytecode on any device with a Java Interpreter. – Because you do not have to recompile the program for each machine, Java is device independent. • Java is safe. The Java language and compiler restrict certain operations to prevent errors. – Would you want an application to have total control of your phone? • Make calls, send SMS messages? • Java standardizes many useful structures and operations such as lists, managing network connections, and providing graphical user interfaces
  • 9. http://aiti.mit.eduAfrica Information Technology Initiative © 2009 Disadvantages of Using Java • Running bytecode through an interpreter is not as fast as running machine code – But this disadvantage is slowly disappearing • Using device specific features (e.g., bluetooth) is difficult sometimes because Java is device- independent. • In order to run a Java program on multiple devices, each must have a Java Interpreter – Ex: most Nokia phones come with Java Interpreter
  • 10. http://aiti.mit.eduAfrica Information Technology Initiative © 2009 Programming Methodology 1. Specify and analyze the problem • Remove ambiguity • Decide on inputs/outputs and algorithms 1. Design the program solution • Organize problem into smaller pieces • Identify existing code to reuse! 1. Implementation (programming) 2. Test and verify implementation 3. Maintain and update program
  • 11. http://aiti.mit.eduAfrica Information Technology Initiative © 2009 Writing Good Code • A program that meets specification is not necessarily good. • Will you be able to make changes to it? – Will you understand it after some time? • Others might need to look at your code – Can they understand it? • Write your program so that is easy to understand and extend! – Spend extra time thinking about these issues.
  • 12. http://aiti.mit.eduAfrica Information Technology Initiative © 2009 Example Code: Comments /* The HelloWorld class prints “Hello, World!” to the screen */ public class HelloWorld { public static void main(String[] args) { // Prints “Hello, World!” System.out.println("Hello, World!"); // Exit the program System.exit(0); } }
  • 13. http://aiti.mit.eduAfrica Information Technology Initiative © 2009 Comments • Comments are used to describe what your code does as an aid for you or others reading your code. The Java compiler ignores them. • Comments are made using //, which comments to the end of the line, or /* */, which comments everything inside of it (including multiple lines) • Two example comments: – /* The HelloWorld class prints “Hello, World!” to the screen */ – // Prints “Hello, World!”
  • 14. http://aiti.mit.eduAfrica Information Technology Initiative © 2009 Comments on Commenting • You may collaborate on software projects with people around the world who you’ll never meet • Should be able to figure out how code works by reading comments alone • Anything that is not self-evident needs a comment • 50% of your code might be comments • Coding is easy, commenting is not

Editor's Notes

  • #5: two step process!
  • #7: the interpreter is called the JRE
  • #8: much easier to standardize the interpreter, this is a piece of software that Sun releases for different platforms and programmers do not have to worry about the specifics of the machines they are targeting or distributing multiple machine codes. Can have a single compiled program (bytecode) run on anything there is an interpreter for. For example, a website with java code does not have to worry about the specific machine that is being used by the viewer. It is up to the user to get the interpreter.
  • #11: very important to think about the problem and solution and create a design document… program is not static! it is always evolving. must make the code as understandable as possible, to yourselves and to others… very important that code is well designed