Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Java. What is Java? A computer programming language that can be run as either an application or an applet. –What is the difference? It.

Similar presentations


Presentation on theme: "Introduction to Java. What is Java? A computer programming language that can be run as either an application or an applet. –What is the difference? It."— Presentation transcript:

1 Introduction to Java

2 What is Java? A computer programming language that can be run as either an application or an applet. –What is the difference? It is considered to be a high-level language. Designed in the early 90’s by a team from ??? What is the difference between Java and JavaScript ? How did java get its name? –http://www.javaworld.com/javaworld/jw-10- 1996/jw-10-javaname.fullquote.htmlhttp://www.javaworld.com/javaworld/jw-10- 1996/jw-10-javaname.fullquote.html

3 Java is… Parsimonious – that is it has a compact set of commands without numerous versions or changes Robust- it supports the development of programs that do not accidentally overwrite data or corrupt data A Strongly typed language – in that its compiler provides extensive checking for potential problems Secure – its programs are easy to protect from viruses. Portability/platform independent – can be used on multiple operating systems

4 Why Learn Java? Good Paying Careers It’s just a good fun language to know

5 Java Components Program source Compiler Bytecode Interpreter Java Virtual Machine Java Runtime Environment IDE- Integrated Development Environement

6 The Java Program Development Life Cycle Analyze the problem Design the program Code the program Test the program Formalize the solution Maintain the program

7 Algorithms A clear and unambiguous specification of the steps needed to solve a problem. Correct – using a logical constructs and valid data in an organized way so that the steps will be carried out correctly and the program will make suitable responses to invalid data, ie warning messages Efficient – refers to the program’s ability to deliver a result in a short time frame to be useful and using as little memory as possible

8 Understanding FlowCharts Process Symbol Input/Output Symbol Flowline Symbol Annotation Symbol Decision Symbol Terminal Symbol Connecter Symbol Predefined Process Symbol

9 Control Structures No matter what procedures (or progression of logical actions) that you wish the computer to perform they can be broken down into these three categories –Sequence Control –Selection Control Case Control –Repetition Control Nested

10 Java as an Object-Oriented Language Still has many different definitions, but the general concept is to package functions together while not restricting data types. –Ie the open desk example

11 Object- Speak Nouns –Object – anything real or abstract about which you both store data and operations that manipulate the data –Class- an object or set of objects that share a common structure and common behavior. Subclass superclass

12 Object Speak Cont Generalization hierarchy –An OO design tool used to show the relationships among classes Data abstraction –Process of creating new high-level data structures based on a defined object through a set of interface operations instead of by directly manipulating the object Instance – unique object or specific occurrence of a class of objects –Ie a two-player button

13 Verbs Operation – activity that reads or manipulates the data of an object. Message defines the interaction of the object External trigger Process that causes an operation to occur is an event –Event diagram page 1.13

14 Adjectives Attributes are identifying characteristics of individual objects, such as name, size, or color.

15 Other terms Encapsulation –Process of hiding the implementation details of an object from its user by combining attributes and methods –Inheritance Concept that programmers can use a class along with functions and data to create a descendent class or subclass Polymorphism –Allows instructions to be given to an object in a generalized rather than specific detailed command, ie where specific actions are different, results are the same

16 Lets look at an Actual Java Program /* Project 1 Printing on the screen Programmer:Carl Rebman Date:4 March 2003 Program NameCarl */ public class carl { public static void main(String [] args) //method header { System.out.println("Carl's Antiques"); System.out.println("208 Olin Hall"); System.out.println("San Diego, CA 92110"); }

17 How do you run it? First step is to have the JDK loaded Second step (after program is written) is to compile the program –Go to command prompt –Set prompt to location of JDK compiler –In this case should be path=c:\jdk1.2.2\bin –Next change to the directory your program is in—should be A:\

18 Running the program cont. Once path has been set and proper directory has been established Run compiler –javac Program_Name.java If successful you’ll get the command prompt again If not, you see a list of errors When there are no errors, run program by typing in –java Progam_Name

19 So what does the code mean? public class Carl { –A class must be defined in every java program –Public is used as a modifer that describe other classes’s access to this class This becomes more important as your programs get more complex –Basically this line starts your program called Carl, and the brackets contain its guts

20 public static void main(String [] args) Methods are the groups of statements that are executed by your computer when instructed to do so. The main method actually drives the java applications –It is the first place the Java VM looks when you run your application

21 Public versus static Public makes this method accessible from all other classes Static ensures there is only one reference to this method Void means that the method does not return any value when completed The Strings[args] means that it is an array list of command-line arguments

22 Comments Single line—begins with // Multiple line begin with /* and end with */

23 Moving up to an Applet Again what is an applet?

24 How to run an Applet Type at the command prompt –appletviewer FILE_NAME.html

25 Special Code import java.awt.Graphics; –This does actually import a class called Graphics –This is a previously defined class of which you can call Extends java.applet Applet –This increases the import and allows for extending the class You get to reuse the functionality of the class Which means when class A extend class B, class A becomes a superclass, and class B becomes a subclass

26 Now lets write our first JAVA program Project 1 in book


Download ppt "Introduction to Java. What is Java? A computer programming language that can be run as either an application or an applet. –What is the difference? It."

Similar presentations


Ads by Google