SlideShare a Scribd company logo
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)

DOCX
JAVA First Day
PPT
1.INTRODUCTION TO JAVA_2022 MB.ppt .
PPTX
JAVA Module 1______________________.pptx
PPTX
java intro.pptx
PPTX
Introduction to java
PPTX
Introduction to java
PPT
Chapter 1 java
PPTX
Object oriented programming-with_java
PPTX
Object oriented programming
PPTX
Object oriented programming-with_java
PPTX
Object oriented programming
PPTX
Object oriented programming-with_java
PPTX
Object oriented programming
PPTX
Object oriented programming
PPT
Servlets and JavaServer Pages (JSP) from the B.Sc. Computer Science and Infor...
PPT
Core Java Slides
PPTX
Learn java theory presentation
PDF
Java Programming
PPT
JAVA object oriented programming (oop).ppt
PPSX
Java Semimar Slide (Cetpa)
JAVA First Day
1.INTRODUCTION TO JAVA_2022 MB.ppt .
JAVA Module 1______________________.pptx
java intro.pptx
Introduction to java
Introduction to java
Chapter 1 java
Object oriented programming-with_java
Object oriented programming
Object oriented programming-with_java
Object oriented programming
Object oriented programming-with_java
Object oriented programming
Object oriented programming
Servlets and JavaServer Pages (JSP) from the B.Sc. Computer Science and Infor...
Core Java Slides
Learn java theory presentation
Java Programming
JAVA object oriented programming (oop).ppt
Java Semimar Slide (Cetpa)

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)

PDF
01-Introduction-to-Information-Management.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Cell Types and Its function , kingdom of life
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Classroom Observation Tools for Teachers
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Institutional Correction lecture only . . .
PDF
Insiders guide to clinical Medicine.pdf
01-Introduction-to-Information-Management.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Supply Chain Operations Speaking Notes -ICLT Program
TR - Agricultural Crops Production NC III.pdf
Microbial diseases, their pathogenesis and prophylaxis
Cell Types and Its function , kingdom of life
VCE English Exam - Section C Student Revision Booklet
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Classroom Observation Tools for Teachers
PPH.pptx obstetrics and gynecology in nursing
2.FourierTransform-ShortQuestionswithAnswers.pdf
RMMM.pdf make it easy to upload and study
Basic Mud Logging Guide for educational purpose
Institutional Correction lecture only . . .
Insiders guide to clinical Medicine.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