Download presentation
Presentation is loading. Please wait.
Published byVirginia Daniel Modified over 8 years ago
1
Introduction To JAVA By Ihtesham Ul Haq
2
Course Objectives Upon completing the course, you will understand Upon completing the course, you will understand Create, compile, and run Java programs Create, compile, and run Java programs Primitive data types Primitive data types Java control flow Java control flow Methods Methods Arrays (for teaching Java in two semesters, this could be the end) Arrays (for teaching Java in two semesters, this could be the end) Object-oriented programming Object-oriented programming Core Java classes (Swing, exception, internationalization, multithreading, multimedia, I/O, networking, Java Collections Framework) Core Java classes (Swing, exception, internationalization, multithreading, multimedia, I/O, networking, Java Collections Framework)
3
Course Objectives, cont. You will be able to You will be able to Write simple programs using primitive data types, control statements, methods, and arrays. Write simple programs using primitive data types, control statements, methods, and arrays. Create and use methods Create and use methods Develop a GUI interface and Java applets Develop a GUI interface and Java applets Write interesting projects Write interesting projects Establish a firm foundation on Java concepts Establish a firm foundation on Java concepts
4
History Of Java In January of 1991, Bill Joy, James Gosling, Mike Sheradin, Patrick Naughton and several other individuals met in Aspen, Colorado for the first time to discuss the ideas for the Stealth Project. The goal of the Stealth Project was to do research in the area of application of computers in the consumer electronics market. The vision of the project was to develop "smart" consumer electronic devices that could all be centrally controlled and programmed from a handheld-remote-control-like device. According to Gosling, "the goal was... to build a system that would let us do a large, distributed, heterogeneous network of consumer electronic devices all talking to each other." With this goal in mind, the stealth group began work In January of 1991, Bill Joy, James Gosling, Mike Sheradin, Patrick Naughton and several other individuals met in Aspen, Colorado for the first time to discuss the ideas for the Stealth Project. The goal of the Stealth Project was to do research in the area of application of computers in the consumer electronics market. The vision of the project was to develop "smart" consumer electronic devices that could all be centrally controlled and programmed from a handheld-remote-control-like device. According to Gosling, "the goal was... to build a system that would let us do a large, distributed, heterogeneous network of consumer electronic devices all talking to each other." With this goal in mind, the stealth group began work
5
History cont. Gosling thought that the C++ programming language used at that time was inadequate for this kind of a project. Gosling thought that the C++ programming language used at that time was inadequate for this kind of a project. His extensions and modifications to C++ were the first steps towards the development of an independent language that would fit the project objectives. His extensions and modifications to C++ were the first steps towards the development of an independent language that would fit the project objectives.
6
The Name Gosling named the language "Oak" while staring at an oak tree outside his office window! The name "Oak" was later dismissed. Gosling named the language "Oak" while staring at an oak tree outside his office window! The name "Oak" was later dismissed. Finally, inspiration struck one day during a trip to the local coffee shop". Finally, inspiration struck one day during a trip to the local coffee shop". Others have speculated that the name Java came from several individuals involved in the project: James gosling, Arthur Van hoff, Andy bechtolsheim. [McCarthy] Others have speculated that the name Java came from several individuals involved in the project: James gosling, Arthur Van hoff, Andy bechtolsheim. [McCarthy]McCarthy
7
Why Choose Java? Why Choose Java? Java is simple Java is simple Java is object-oriented Java is object-oriented Java is distributed Java is distributed Java is interpreted Java is interpreted Java is robust Java is robust Java is secure Java is secure Java is architecture-neutral Java is architecture-neutral Java is portable Java is portable Java’s performance Java’s performance Java is multithreaded Java is multithreaded Java is dynamic Java is dynamic
8
Java is Architecture Neutral! The most important of the advantages of java over others is that the Language is Architecture Neutral. The most important of the advantages of java over others is that the Language is Architecture Neutral. This means that a Program written in java can be run by “Any Machine” having “Any operating System”. This means that a Program written in java can be run by “Any Machine” having “Any operating System”.
9
How Does the Architecture Neutral Work?
10
Anatomy of a Java Program Comments Comments Package Package Reserved words Reserved words Modifiers Modifiers Statements Statements Blocks Blocks Classes Classes Methods Methods The main method The main method
11
Comments In Java, comments are preceded by two slashes (//) in a line, or enclosed between /* and */ in one or multiple lines. When the compiler sees //, it ignores all text after // in the same line. When it sees /*, it scans for the next */ and ignores any text between /* and */.
12
Package The second line in the program (package chapter1;) specifies a package name, chapter1, for the class Welcome. Packages are Groups of classes Located in a directory, child directory, and so on…. It is important to note that in a program we may include a package name or a sub package name.
13
Reserved Words Reserved words or keywords are words that have a specific meaning to the compiler and cannot be used for other purposes in the program. For example, when the compiler sees the word class, it understands that the word after class is the name for the class. Other reserved words are public, static, and void.
14
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.
15
Statements A statement represents an action or a sequence of actions. The statement System.out.println("Welcome to Java!") in the program in Example 1.1 is a statement to display the greeting "Welcome to Java!" Every statement in Java ends with a semicolon (;).
16
Blocks A pair of braces in a program forms a block that groups components of a program.
17
Classes The class is the essential Java construct. 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. The mystery of the class will continue to be unveiled throughout Java. For now, though, understand that a program is defined by using one or more classes.
18
Methods What is System.out.println? It is a method: a collection of statements that performs a sequence of operations to display a message on the console. It can be used even without fully understanding the details of how it works. It is used by invoking a statement with a string argument. The string argument is enclosed within parentheses. In this case, the argument is "Welcome to Java!" You can call the same println method with a different argument to print a different message.
19
main Method The main method provides the control of program flow. The Java interpreter executes the application by invoking the main method. The main method looks like this: public static void main(String[] args) { // Statements; // Statements;}
20
What tools to Use? JDK 6 JDK 6 The Java Development Kit Version 6 The Java Development Kit Version 6 Can be downloaded from http://www.sun.java.com/ Can be downloaded from http://www.sun.java.com/ TEXTPAD TEXTPAD IDE for Java Development IDE for Java Development Can be downloaded from Can be downloaded fromhttp://www.textpad.com/
21
Recommended Books Java 2 Java 2 Ivor Horton Ivor Horton Java Java Dietel and Dietel Dietel and Dietel
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.