Using the Java API

Slides:



Advertisements
Similar presentations
1 StringBuffer & StringTokenizer Classes Chapter 5 - Other String Classes.
Advertisements

STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Packages, Characters, Strings Arguments to method main CS2110, Week 2 Recitation 1.
University of British Columbia CPSC 111, Intro to Computation Jan-Apr 2006 Tamara Munzner Objects, Methods, Parameters, Input Lecture 5, Thu Jan
11-Jun-15 Using the Java API
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 9 Characters and Strings (sections ,
1 Java intro Part 3. 2 Arrays in Java Store fixed number of values of a given type Arrays are objects –have attributes –must be constructed Array declaration:
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.
Java Library Java provides a huge library or collection of useful programs A gold mine of well-tested code that can save you countless hours of development.
More sophisticated behavior Using library classes to implement some more advanced functionality 4.0.
26-Jun-15 Abstract Data Types. 2 Data types I We type data--classify it into various categories-- such as int, boolean, String, Applet A data type represents.
Grouping Objects 1 Introduction to Collections.
29-Jun-15 Using the Java API
1 More on Arrays Arrays of objects Command line arguments The ArrayList class Javadoc Review Lecture 8 notes and L&L 7.1 – 7.2 Reading for this lecture:
JAVA LIBRARY CLASSES CITS Main concepts to be covered Using library classes: String, Math, Color Reading documentation Java 7 API is available.
MIT AITI 2003 Lecture 7 Class and Object - Part I.
JavaDoc COMP 302. JavaDoc javadoc: The program to generate java code documentation. Input: Java source files (.java)  Individual source files  Root.
1 Documenting with Javadoc CS 3331 Fall 2009 How to Write Doc Comments for the Javadoc TM Tool available from java.sun.com.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Recitation 2 Main Method, API & Packages, Java Basics.
Java Packages and Libraries M Taimoor Khan
Characters The data type char represents a single character in Java. –Character values are written as a symbol: ‘a’, ‘)’, ‘%’, ‘A’, etc. –A char value.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
1 Documenting with Javadoc. 2 Motivation  Why document programs? To make it easy to understand, e.g., for reuse and maintenance  What to document? Interface:
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
String Processing Opening Discussion zDo you have any questions about the quiz? zWhat did we talk about last class? zDo you have questions.
23-Oct-15 Abstract Data Types. 2 Data types A data type is characterized by: a set of values a data representation, which is common to all these values,
 Character set is a set of valid characters that a language can recognise.  A character represents any letter, digit or any other sign  Java uses the.
Javadoc Comments.  Java API has a documentation tool called javadoc  The javadoc tool is used on the source code embedded with javadoc-style comments.
Documentation Array and Searching. Documentation rules Easy rules: –Naming convention for variables, constants and methods Difficult rules: –Professional.
10-Nov-15 Java Object Oriented Programming What is it?
Javadoc A very short tutorial. What is it A program that automatically generates documentation of your Java classes in a standard format For each X.java.
Java Overview. Comments in a Java Program Comments can be single line comments like C++ Example: //This is a Java Comment Comments can be spread over.
Javadoc Dwight Deugo Nesa Matic
JavaDoc and Contracts Spring Documenting Contracts with JavaDoc Contract model for methods Preconditions Postconditions JavaDoc Industry standard.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming1 Programming.
Appendix E Using the Java API Documentation 報告人:黃偉倫 學號:
Abstract Classes and Interfaces Chapter 9 CSCI 1302.
Javadoc. Purpose of javadoc javadoc is a program that reads your Java program and produces great-looking documentation in HTML format Without any help,
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.
Page 1 – Autumn 2009Steffen Vissing Andersen SDJ I1, Autumn 2009 Agenda: Java API Documentation Code Documenting (in javadoc format) Debugging.
Computer Science 209 Software Development Handing Errors and Creating Documentation.
Java Doc Guideline R.SANTHANA GOPALAN. Java Doc Guideline Audience Internal Developers PQA - who write test plans PPT – who write the documentation Customers.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
Java Classes Chapter 1. 2 Chapter Contents Objects and Classes Using Methods in a Java Class References and Aliases Arguments and Parameters Defining.
1 Documenting with Javadoc CS 3331 Section and Appendix B of [Jia03] How to Write Doc Comments for the Javadoc TM Tool available from
SourceAnatomy1 Java Source Anatomy Barb Ericson Georgia Institute of Technology July 2008.
Arguments to method main, Packages, Wrapper Classes, Characters, Strings CS2110, Recitation 2.
1 Documenting with Javadoc How to Write Doc Comments for the Javadoc TM Tool available from java.sun.com.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.
Variable Scope & Lifetime
More on Arrays Review of Arrays of ints, doubles, chars
Using the Java Collection Libraries COMP 103 # T2
Objects as a programming concept
More Sophisticated Behavior
CS2110, Recitation 1 Arguments to method main, Packages, Wrapper Classes, Characters, Strings.
CS2110, Recitation 1 Arguments to method main, Packages, Wrapper Classes, Characters, Strings.
CSE 413, Autumn 2002 Programming Languages
Session 2 What you already know about Java Reading and using an API
Classes, Libraries & Packages
Unit-2 Objects and Classes
Introduction to Java part 2
Abstract Class As per dictionary, abstraction is the quality of dealing with ideas rather than events. For example, when you consider the case of ,
Object Oriented Programming in java
JavaDoc and Contracts Fall 2008.
Java Programming Review 1
String Class.
Presentation transcript:

Using the Java API

Overview Classes Packages Views Main Information Area

General approach If you know the name of the package, click it in the upper left panel; or click All Classes Click on the class in the lower left panel Scroll in the right pane to find the summary of the field, method, or constructor you want –Or just read the general description For more information, click the link in the summary to go to the detailed information

The Packages panel Choose the package you are interested in Or, choose All Classes Classes in java.lang are automatically imported into every program--you don’t have to do it yourself

The Classes panel This panel shows both classes and interfaces We haven’t yet talked about interfaces Note that some classes have names similar to primitive types ( Boolean, Byte, Character )

The links bar Overview is where you start out Index is handy for looking up methods Help is the obvious If you don’t like frames, you can choose NO FRAMES Deprecated methods are those that have been replaced by better methods and should not be used

The main information area General description of the class Field summary Constructor summary Method summary Field detail Constructor detail Method detail In each case, the “summary” is the first sentence of the “detail”

Reading the method descriptions I An example from the String class: –public char charAt(int index) Returns the character at the specified index –public means accessible from anywhere –char is the return type –charAt is the name of the method –int is the type of parameter expected –index is just a suggestive name –Example use: char firstChar = myStr.charAt(0);

Reading the method descriptions II Another example from the String class: –public static String valueOf(int i) Returns the string representation of the int argument. –public means accessible from anywhere –static means this is a class method (see use below) –String is the return type, and is a hyperlink –valueOf is the name of the method –int is the type of parameter expected –i is just a suggestive name –Example use: String numeral = String.valueOf(m / n);

How was this documentation produced? All Java documentation was produced by the javadoc program from javadoc (or just doc) comments in the source code Your doc comments can be used in the same way to produce professional-looking documentation The Interface menu item in BlueJ does the same basic thing as javadoc –Like most things in BlueJ, fancy features have been omitted in the interests of simplicity

Value of the API Java 1.2 gives you 60 packages containing 1781 classes and interfaces, 3538 fields, 2337 constructors, and methods You can only learn a small fraction of these When you learn the kinds of things that are in the API, and learn to find your way around in it, you become a far more effective and efficient programmer A good craftsman knows his/her tools

The End