1 / 21

Introduction To JAVA

Introduction To JAVA. By Ihtesham Ul Haq. Course Objectives. Upon completing the course, you will understand Create, compile, and run Java programs Primitive data types Java control flow Methods Arrays (for teaching Java in two semesters, this could be the end)

anniedsmith
Download Presentation

Introduction To JAVA

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction To JAVA By Ihtesham Ul Haq

  2. Course Objectives • Upon completing the course, you will understand • Create, compile, and run Java programs • Primitive data types • Java control flow • Methods • Arrays (for teaching Java in two semesters, this could be the end) • Object-oriented programming • Core Java classes (Swing, exception, internationalization, multithreading, multimedia, I/O, networking, Java Collections Framework)

  3. Course Objectives, cont. • You will be able to • Write simple programs using primitive data types, control statements, methods, and arrays. • Create and use methods • Develop a GUI interface and Java applets • Write interesting projects • 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

  5. History cont. • 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.

  6. The Name • 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". • Others have speculated that the name Java came from several individuals involved in the project: James gosling, Arthur Van hoff, Andy bechtolsheim. [McCarthy]

  7. Why Choose Java? • Java is simple • Java is object-oriented • Java is distributed • Java is interpreted • Java is robust • Java is secure • Java is architecture-neutral • Java is portable • Java’s performance • Java is multithreaded • 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. • 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 • Package • Reserved words • Modifiers • Statements • Blocks • Classes • Methods • 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; }

  20. What tools to Use? • JDK 6 • The Java Development Kit Version 6 • Can be downloaded from http://www.sun.java.com/ • TEXTPAD • IDE for Java Development • Can be downloaded from http://www.textpad.com/

  21. Recommended Books • Java 2 • Ivor Horton • Java • Dietel and Dietel

More Related