Java 3 More Java Then Java. Libraries & Packages Java standard class library is composed of useful classes that help us to achieve our programming goals.

Slides:



Advertisements
Similar presentations
In Review JAVA C++ GUIs - Windows Webopedia.com.
Advertisements

Java Applets:. How Applets differ from application?: They do not use main method but init(), start() and paint() methods of the applet class They can.
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
Chapter 3 - Java Programming With Supplied Classes1 Chapter 3 Java Programming With Supplied Classes.
got ? Research Project – April 1998 Hang Xia, Mark Wang, Richard S. Chang Updated: R Norman, August 1999.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 - Introduction to Java Applets Outline 3.1 Introduction 3.2 Sample Applets from the Java 2.
1 Introduction to Applets Overview l What is an Applet? l Steps for creating an applet l What is HTML? l Basic HTML tags l Drawing Simple Graphical shapes.
Java Applets. Road Map Introduction to Java Applets Review applets that ship with JDK Make our own simple applets –Introduce inheritance –Introduce the.
Introduction to Java CS 331. Introduction Present the syntax of Java Introduce the Java API Demonstrate how to build –stand-alone Java programs –Java.
1 Chapter 3 Programs and Packages. 2 Java Virtual Machine (JVM) Java programs execute on the JVM. The JVM is a virtual rather than a physical machine,
Chapter 3 Using Classes and Objects. 2 Creating Objects  A variable holds either a primitive type or a reference to an object  A class name can be used.
Object Oriented Programming (OOP) LAB # 5 TA. Maram & TA. Mubaraka TA. Kholood & TA. Aamal.
References, Aliases, Garbage Collection and Packages Packages and Importing Classes Reading for this Lecture: L&L, Familiarize yourself with.
Java Software Solutions Lewis and Loftus Chapter 2 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Software Concepts -- Introduction.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
Introduction to Java Programming CS 21a: Introduction to Computing I Department of Information Systems and Computer Science Ateneo de Manila University.
Introduction to Java Programming CS 21a: Introduction to Computing I First Semester,
Java Programming, 3e Concepts and Techniques Chapter 2 - Part 2 Creating a Java Application and Applet.
Some Special Issues (c) IDMS/SQL News
Class Library, Formatting, Wrapper Classes, and JUnit Testing
Chapter 2: Objects and Primitive Data Classes and Objects String, Random, Math, NumberFormat, DecimalFormat and Wrapper Classes.
Java Lecture 16: Dolores Zage. WWW n Was a method for distributing passive information n added forms and image maps n interaction was only a new way to.
JAVA APPLETS By: Ms. Humaira Siddiqui. Java and the Internet Java is considered to be a language well suited to be used in the internet. In contrast with.
Applets.
Chapter 34 Java Technology for Active Web Documents methods used to provide continuous Web updates to browser – Server push – Active documents.
1 Computer Systems -- Introduction  Chapter 1 focuses on:  the structure of a Java application  basic program elements  preparing and executing a program.
Java Applets. 2 Introduction to Java Applet Programs  Applications are stand alone programs executed with Java interpreter executed with Java interpreter.
Introduction to Computer Systems and the Java Programming Language.
CS591x A very brief introduction to Java. Java Developed by Sun Microsystems was intended a language for embedded applications became a general purpose.
Java 2 More Java Then Starbucks ;-). Important Terms Primitive Data – Basic, built-in values (characters & numbers) Data Type – Used to talk about values.
1 The String Class Every character string is an object in Java, defined by the String class Every string literal, delimited by double quotation marks,
Introduction to Java Applets Sangeetha Parthasarathy 05/21/2001.
Intro to Applets August 19, 2008 Mrs. C. Furman. Java Applets vs. Java Applications Java Applet: a program that is intended for use on the web. Java Applet:
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
Chapter 2: Color and Applets Coming up: Introduction to Graphics.
Java applets. Outline What is Java? Java Applications Java Applets Java Applets Securities Summary.
1 Programming Java Java Basics. 2 Java Program Java Application Program Application Program written in general programming language Applet Program running.
Lecture 2 Software Concepts Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
Java -- A very Hot Object- Oriented Language Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of.
Your name CSCI/CMPE 3326 Object-Oriented Programming in Java Dongchul Kim Department of Computer Science University of Texas – Pan American 1.Applet.
Java Software Solutions Lewis and Loftus Chapter 2 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Software Concepts -- Introduction.
Creating a Java Application and Applet
CSI 3125, Preliminaries, page 1 Applet. CSI 3125, Preliminaries, page 2 Applet An applet is a Java program that runs in a Web browser. An applet can be.
1 Introduction to Graphics b The last one or two sections of each chapter of the textbook focus on graphical issues b Most computer programs have graphical.
1 Chap. 3 Creating Objects The String class Java Class Library (Packages) Math.random() Reading for this Lecture: L&L, 3.1 – 3.6.
Java Programming, Second Edition Chapter Twelve Advanced Inheritance Concepts.
Packages. The main feature of OOP is its ability to support the reuse of code: –Extending the classes –Extending interfaces The features in basic form.
1 Wrapper Classes  Sometimes we want to use a primitive type as an object, so there are wrapper classes that will help us.  In particular, we need to.
Programming in Java (COP 2250) Lecture 7 Chengyong Yang Fall, 2005.
IT11 Agenda for Feb Golden Rule Reminder. 2. PowerPoint demonstration on the structure of Java Applet programs. Source Files HTML Files Class Files.
Please open JCreator and follow these steps: 1)Configure  Options 2)JDK Tools 3)Choose Run Applet from drop-down 4)Click Default, then Edit 5)Click the.
WEEK 2 1 Software Concepts -- Introduction Now we can begin to examine the basic ideas behind writing programs Chapter 2 focuses on: history.
1 Applets Programming. Introduction Java programs are divided into two main categories, applets and applications. An application is an ordinary Java program.
1 Creating Objects  A variable holds either a primitive type or a reference to an object  A class name can be used as a type to declare an object reference.
Variables in Java A variable holds either
Chapter Two Applet vs. Application
What is Java?.
Classes, Libraries & Packages
Switch, Rounding Errors, Libraries
Java Applets.
Applet in Java.
11.1 Applets & graphics.
Chap 1. Getting Started Objectives
Outline Character Strings Variables and Assignment
Chap 4. Programming Fundamentals
JAVA APPLET PREPARED BY Mr. Jahanzaib Ahmed
Enabling Application Delivery Via the Web
Drawing Shapes (Graphics Class) Creating Objects Packages
APPLET PROGRAMMING.
Presentation transcript:

Java 3 More Java Then Java

Libraries & Packages Java standard class library is composed of useful classes that help us to achieve our programming goals but are not a part of the Java language Java packages are groups of classes that we can call by a single name…the String class is part of the java.lang package. Some packages are listed on p. 94

Class Libraries “Set of classes that supports the development of programs.” Included with compiler or available from 3 rd party vendors. Provide common methods programmers come to depend on.

Packages Groups of related packages. String class is part of the java.lang package. Some packages contain many classes so be careful when using “*” imports.

Importing Classes Java.lang packages are automatically available to every program we write. To access other packages we must use a fully qualified reference to the package or import it. import java.util.*; import cs1.Keyboard;

Class Methods Also called static methods. Invoked through the class name. Examples: Math.pow(2,8); Keyboard.readInt();

Applets Java programs intended to be run using a Web browser. Can also be viewed using Sun’s appletviewer. Applets don’t have a “main” method. Graphical applets need to import… java.applet.Applet java.awt.*

Applets Cont’d. Classes that define applets inherit from the master Applet class. In Java terms, they EXTEND the Applet class. Applet classes must be public (more on this later) Must be bytecode before being downloaded by the browser ( a.class file)

Applets Cont’d. Applets are embedded in HTML pages using the tag.

Basic Conditional Statements if (this > that) { this++; } else { that++; }

Basic Conditional Statements // single line shortcut if (this > that) this++; else that++;

Basic Conditional Statements Equality Operators… == equal to !=not equal to greater than >=greater than or equal to

More Conditionals if (this > that) this++; else if that++; else if theotherthing++; else nothing++;

Logical Operators Logical Operators… ! not &&and ||or

More Operators Increment and Decrement ++Increment I = I Decrement I = I - 1

Switch Statements switch(something) case ‘y’: this++; break; case ‘n’: that++; break;

Comparing Strings Don’t use ==, we’ll discuss that later. Do use objname.equals(otherobj); objname.compareTo(otherobj);

Comparing Floats Watch your precision. “==“ compares ONLY the underlying binary representations and it is unlikely they will match. Do use the absolute value of the difference of 2 numbers and compare to a pre-set value. final float TOLERANCE =.01; if(Math.abs(fl1 – fl2) < TOLERANCE) System.out.println(“Equal enough”);