2.3 The Java API Documentation. What follows are the contents of the Java Application Programming Interface (API) Documentation for the system supplied.

Slides:



Advertisements
Similar presentations
Classes And Objects II. Recall the LightSwitch Class class LightSwitch { boolean on = true; boolean isOn() { return on; } void switch() { on = !on; }
Advertisements

Chapter 4 (Horstmann’s Book) Interface Types and Polymorphism: Graphics, Timer, Animation Hwajung Lee.
SUMMARY: abstract classes and interfaces 1 Make a class abstract so instances of it cannot be created. Make a method abstract so it must be overridden.
Topic 5a – Interfaces Friends share all things. CISC370/Object Oriented Programming with Java.
16-Jun-15 javadoc. 2 Javadoc placement javadoc comments begin with /** and end with */ In a javadoc comment, a * at the beginning of the line is not part.
Chapter 2 storing numbers and creating objects Pages in Horstmann.
A Simple Applet.
1 More on Classes Overview l Overloading l The this keyword l The toString method l The equals method.
Java Unit 5: Applets and Graphics Web Pages and Viewing Applets.
1 Object-Oriented Programming (Java), Unit 13 Kirk Scott.
Chapter 11 Abstract Classes and Interfaces 1. Abstract method New modifier for class and method: abstract An abstract method has no body Compare: abstract.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
University of Limerick1 Work with API’s. University of Limerick2 Learning OO programming u Learning a programming language can be broadly split into two.
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
CS1101X: Programming Methodology Recitation 7 Arrays II.
Packages. Package A package is a set of related classes Syntax to put a class into a package: package ; public class { …} Two rules:  A package declaration.
Introduction to Programming Writing Java Beginning Java Programs.
Polymorphism, Inheritance Pt. 1 COMP 401, Fall 2014 Lecture 7 9/9/2014.
Java Packages and Libraries M Taimoor Khan
2000 Jordan Anastasiade. All rights reserved. 1 Class In this lesson you will be learning about: Class. Inheritance. Polymorphism. Nested and.
Objects and Classes Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary.
Generic Programming  Object Type  Autoboxing  Bag of Objects  JCL Collections  Nodes of Objects  Iterators.
1 Object state: fields. Fields field: A variable inside an object that represents part of its internal state.  Each object will have its own copy of.
1 Principles of Computer Science I Prof. Nadeem Abdul Hamid CSC 120 – Fall 2005 Lecture Unit 2 - Using Objects.
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Introduction to Programming Writing Java Beginning Java Programs.
CS1101: Programming Methodology Aaron Tan.
Chapter 14 Abstract Classes and Interfaces. Abstract Classes An abstract class extracts common features and functionality of a family of objects An abstract.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
Chapter 5 Objects and Classes Inheritance. Solution Assignments 3 & 4 Review in class…..
Lesson 6 – Libraries & APIs Libraries & APIs. Objective: We will explore how to take advantage of the huge number of pre-made classes provided with Java.
Lecture 9.4 Java Interfaces. © 2006 Pearson Addison-Wesley. All rights reserved Java does not support multiple inheritance. Interface Characteristics...
Chapter 7: Class Inheritance F Superclasses and Subclasses F Keywords: super and this F Overriding methods F The Object Class F Modifiers: protected, final.
CS1101: Programming Methodology
Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Access Modifiers Control which classes use a feature Only class-level variables may be controlled by access modifiers Modifiers 1. public 2. protected.
Chapter 4 Interface Types and Polymorphism: Graphics, Timer, Animation.
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Attribute - CIS 1068 Program Design and Abstraction Zhen Jiang CIS Dept. Temple University SERC 347, Main Campus 12/24/2016.
1 Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
SourceAnatomy1 Java Source Anatomy Barb Ericson Georgia Institute of Technology July 2008.
1 Review for Midterm 2 Aaron Bloomfield CS 101-E.
The Object class Object package java.lang Object clone equals hashCode toString aCopy toThis hash string ! yesOrNo.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Lecture 6:Interfaces and Abstract Classes Michael Hsu CSULA.
Objects and Classes. F OO Programming Concepts F Creating Objects and Object Reference Variables –Differences between primitive data type and object type.
Lecture 5:Interfaces and Abstract Classes
A structured walkthrough
Unit 2: Java Introduction to Programming
Object-Oriented Programming (Java), Unit 13
CSC 205 Java Programming II
Chapter 8 Classes and Objects
Chapter 3: Using Methods, Classes, and Objects
Chapter 10 Thinking in Objects
Object Oriented Programming
Events, Event Handlers, and Threads
Chapter 14 Abstract Classes and Interfaces
Programming with inheritance Based on slides by Alyssa Harding
Chapter 8 Class Inheritance and Interfaces
Chapter 13 Abstract Classes and Interfaces Part 01
Subtype Substitution Principle
Day 11 The Last Week!.
Presentation transcript:

2.3 The Java API Documentation

What follows are the contents of the Java Application Programming Interface (API) Documentation for the system supplied class Point. The complete online Java API documentation can easily be found through a Web search. This is a comprehensive reference for questions about programming in Java. An explanation of the excerpt from the documentation is given following it.

java.awt Class Point java.lang.Object | +--java.awt.geom.Point2D | +--java.awt.Point All Implemented Interfaces: java.lang.Objectjava.awt.geom.Point2D Cloneable, Serializable CloneableSerializable

public class Point extends Point2DPoint2D implements SerializableSerializable A point representing a location in (x, y) coordinate space, specified in integer precision. Since: JDK1.0 See Also: Serialized Form

Inner classes inherited from class java.awt.geom.Point2DPoint2D Point2D.DoublePoint2D.Double, Point2D.FloatPoint2D.Float

Inner classes inherited from class java.awt.geom.Point2DPoint2D Point2D.Double Point2D.Double, Point2D.Float Point2D.Float Field Summary int x x The x coordinate. int y y The y coordinate.

Constructor Summary PointPoint() Constructs and initializes a point at the origin (0, 0) of the coordinate space. PointPoint(int x, int y) Constructs and initializes a point at the specified (x, y) location in the coordinate space. PointPoint(Point p) Constructs and initializes a point with the same location as the specified Point object.Point

Method Summary boolean equalsequals(Object obj) Determines whether an instance of Point2D is equal to this point.Object Point getLocationgetLocation() Returns the location of this point. double getXgetX() Returns the X coordinate of the point in double precision. double getYgetY() Returns the Y coordinate of the point in double precision. void movemove(int x, int y) Moves this point to the specificed location in the (x, y) coordinate plane.

void setLocationsetLocation(double x, double y) Sets the location of this point to the specified float coordinates. void setLocationsetLocation(int x, int y) Changes the point to have the specificed location. void setLocationsetLocation(Point p) Sets the location of the point to the specificed location.Point String toStringtoString() Returns a string representation of this point and its location in the (x, y) coordinate space. void translatetranslate(int x, int y) Translates this point, at location (x, y), by dx along the x axis and dy along the y axis so that it now represents the point ( x + dx, y + dy ).

The information given at the top of the documentation concerns the naming of the class and where it is located. System supplied classes are arranged in packages. If you scan through the information at the top you will eventually find this: java.awt.Point. “awt” stands for “abstract windowing toolkit”. This is the name of a package in Java which includes classes related to doing graphical things.

Point is one of those classes. If a program uses a system supplied class, a line like this is put at the top of the code: import java.awt.Point; The idea is that this will make the class available for use in the program. This will be done in the example programs. It is possible to import all classes in a package at once. If you chose to do this, you would use the * as a wildcard: import java.awt.*;

The next segment of interest in the documentation is entitled “Field Summary”. In the documentation, what are referred to in these notes as instance variables are referred to as fields. In other words, you discover from this documentation that an object created from the Point class will have two instance variables, an x coordinate and a y coordinate. These instance variables are given the type “int”, which signifies that these coordinates can take on integer values.

The next segment in the documentation is entitled “Constructor Summary”. Constructors are special pieces of code used for creating instances of classes. Constructors have a form reminiscent of methods—they have a name followed by a set of parentheses which may or may not contain parameters.

Constructors are not methods. Their name is the same as the class they belong to. As you can see, a single class may have more than one constructor. The system can tell them apart because they have different parameter lists. In the documentation the types of the parameters are shown. For the time being we will restrict our attention to examples with parameters of the type “int”.

The last segment of the documentation is the “Method Summary”. This gives all of the methods by name and all of their parameters by name, including their types. There can be different methods with the same name. The system tells them apart by their parameter lists. It is only through these methods that a program can affect the instance variables, the x and y coordinates, of a Point object that has been created.

As you can see, int and double are two different numeric types. The meaning of types will be covered in the next unit. For the time being, examples will be restricted to the int, or integer type. This type can hold whole number values.