Application Programming Interfaces. Java comes with a bunch of classes that are already written. Java comes with a bunch of classes that are already written.

Slides:



Advertisements
Similar presentations
Java Packages CSci 1130 Intro to Computer Programming with Java Instructor Tatyana Volk.
Advertisements

JAVA Programming Environment © Juhani Välimäki 2003.
Designing Classes Chapter 8. Classes Collection of objects Objects are not actions Class names – Nouns Method names – Verbs What Makes a Good Class Represent.
ECE122 L4: Creating Objects February 8, 2007 ECE 122 Engineering Problem Solving with Java Lecture 4 Creating and Using Objects.
Chapter 3 Using Classes and Objects. Creating Objects A variable holds either a primitive type or a reference to an object A class name can be used as.
Getting Ready for Java. What is Java? Java is a programming language: a language that you can learn to write, and the computer can be made to understand.
Introduction to Java ISYS 350. A Brief History Sun Microsystems released this language in 1996 – Versions: 1.0 – 1.6 Java Development Kit, JDK – Standard.
Chapter 2 Getting Started with Java Part B. Topics Components of a Java Program –classes –methods –comments –import statements Declaring and creating.
Unit2: Object-oriented programming Getting started with Java Jin Sa.
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.
References, Aliases, Garbage Collection and Packages Packages and Importing Classes Reading for this Lecture: L&L, Familiarize yourself with.
15-Jul-15 Getting Ready for Java. What is Java? Java is a programming language: a language that you can learn to write, and the computer can be made to.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
Course: Introduction to Computers
UFCFX5-15-3Mobile Device Development UFCFX Mobile Device Development An Introduction to the Module.
Introduction to Java Tonga Institute of Higher Education.
Introducing Java.
Week71 APCS-AB: Java Control Structures October 17, 2005.
LESSON 2 CREATING A JAVA APPLICATION JAVA PROGRAMMING Compiled By: Edwin O. Okech [Tutor, Amoud University]
Class Library, Formatting, Wrapper Classes, and JUnit Testing
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Chapter 2: Objects and Primitive Data Classes and Objects String, Random, Math, NumberFormat, DecimalFormat and Wrapper Classes.
Java Packages and Libraries M Taimoor Khan
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
Week1 Using the Library (the Java API) Classes are grouped together in packages –To use a class you have to know which package it is in –Every package.
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
Programming Concept Chapter I Introduction to Java Programming.
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,
1 Java Programming 1 Introduction to Basic GUI Lesson 4.
CS 106 Introduction to Computer Science I 01 / 31 / 2007 Instructor: Michael Eckmann.
5-Jun-16 Getting Ready for Java. 2 What is Java? Java is a programming language: a language that you can learn to write, and the computer can be made.
Java Classes, Objects, and Events: A Preview JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria.
Introduction to Processing. 2 What is processing? A simple programming environment that was created to make it easier to develop visually oriented applications.
1 JAVA API & Packages Starring: Java Documentation Co-Starring: BlueJ IDE.
Applets Yong Choi School of Business CSU, Bakersfield.
Class Libraries Chapter 1 1 Source Intro to Java Programming Y. Daniel Liang.
Using methods in the Java library. Previously discussed Method = a collection of statements that performs a complex (useful) task A method is identified.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object.
Introduction to Android
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. A class represents a single concept from the problem domain, or a.
1 Chap. 3 Creating Objects The String class Java Class Library (Packages) Math.random() Reading for this Lecture: L&L, 3.1 – 3.6.
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.
Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Chapter 3: Using Classes and Objects Coming up: Creating Objects.
Programming in Java (COP 2250) Lecture 7 Chengyong Yang Fall, 2005.
April 20, 1998CS102-02Lecture 4-1 A Method to the Madness CS Lecture 4-1 Java's Work Horses.
SourceAnatomy1 Java Source Anatomy Barb Ericson Georgia Institute of Technology July 2008.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
Object Oriented Programming Object and Classes Lecture 3 MBY.
CS 115 OBJECT ORIENTED PROGRAMMING I LECTURE 6_1 GEORGE KOUTSOGIANNAKIS Copyright: FALL 2015 Illinois Institute of Technology- George Koutsogiannakis 1.
Outline Creating Objects The String Class The Random and Math Classes Formatting Output Enumerated Types Wrapper Classes Components and Containers Images.
© 2004 Pearson Addison-Wesley. All rights reserved September 5, 2007 Packages & Random and Math Classes ComS 207: Programming I (in Java) Iowa State University,
Console Input and Output JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin, Gary Litvin,
Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.
© 2004 Pearson Addison-Wesley. All rights reserved3-1 Objects Declaration: String title;  title (object variable) of type String( Class )  title is just.
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.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Variables in Java A variable holds either
Software Development Packages
SOFTWARE and OPERATING SYSTEM.
Java Import Statement Copyright © Curt Hill
Classes, Libraries & Packages
L3. Necessary Java Programming Techniques
L3. Necessary Java Programming Techniques
Creating Objects A variable holds either a primitive value or a reference to an object A class name can be used as a type to declare an object reference.
Packages & Random and Math Classes
Building a program (Java libraries) - an example
CMPE212 – Reminders Assignment 2 due today, 7pm.
Interfaces,Packages and Threads
Presentation transcript:

Application Programming Interfaces

Java comes with a bunch of classes that are already written. Java comes with a bunch of classes that are already written. For example: For example: –Scanner class –Random class To organize these classes, they are put into what is called a package. To organize these classes, they are put into what is called a package.

Package: Package: –A group of related classes. –Think of a package as a “library of classes.” –Each package has a name. For example the Scanner and Random classes are in the “utility” package  This is named “java.util.” –Ex: Scanner class Random class java.util package

API API –“Application Programming Interface” –Is a collection of packages, that give a programmer access to classes that they need to write programs. Scanner class Random class java.util package javax.swing package JOptionPane class Java API

To use the classes from any of these packages, you have to import them from the Java API. To use the classes from any of these packages, you have to import them from the Java API. This is why we have the import statements at the beginning of programs. This is why we have the import statements at the beginning of programs. Ex: Ex: import java.util.Scanner;  This imports the ONLY Scanner class. import java.util.*;  By using a wildcard you import ALL of the classes in the java.util package. (Scanner, Random, etc…) By the way, importing all the classes will not affect the performance OR size of your program. By the way, importing all the classes will not affect the performance OR size of your program. It just tells the compiler that you want to make all the classes in the package available. It just tells the compiler that you want to make all the classes in the package available.

There is one package in the Java API that is automatically imported into EVERY Java program. This is the java.lang package. There is one package in the Java API that is automatically imported into EVERY Java program. This is the java.lang package. Listing of a few standard Java packages: Listing of a few standard Java packages: PackageDescription java.applet Provides classes to write an applet. java.io Provides classes that perform different types of input and output. java.lang Provides general Java classes. This package is automatically imported. java.util Provides various utility classes. javax.swing Provides classes for graphical user interfaces(windows).

APIs are not specific to Java. APIs are not specific to Java. There are APIs for all kinds of things… There are APIs for all kinds of things… Let’s look at the words in API: Let’s look at the words in API: –Application  meaning a program or service (like Google Earth) –Programming  the syntax and ability to write code for a program (like the lava language) –Interface  the classes that let you interact or create part of an application (the packages and classes that let you create stuff for Google Earth)

Videos: Videos: –Google Earth API –API Explanation

Think of an API as a bunch of classes that give you the “key” to creating applications. Think of an API as a bunch of classes that give you the “key” to creating applications. I can’t create something like Google Earth myself, but the folks at Google have released the Google Earth API so that I can USE their classes to create applications that can interact with their Google Earth website. I can’t create something like Google Earth myself, but the folks at Google have released the Google Earth API so that I can USE their classes to create applications that can interact with their Google Earth website. Also, keep in mind that Google will only release classes in the API for things that they want you to do. Also, keep in mind that Google will only release classes in the API for things that they want you to do. APIs give you a way to create programs for applications, but at the same time the companies that create the APIs (like Google’s API for Google Earth) can control what you can and can’t do with their program. APIs give you a way to create programs for applications, but at the same time the companies that create the APIs (like Google’s API for Google Earth) can control what you can and can’t do with their program.

Here are a few examples of APIs: Here are a few examples of APIs: Windows API  contains classes that allow people to create programs for Windows (in the C++ language). Windows API  contains classes that allow people to create programs for Windows (in the C++ language). Greenfoot API  provides the classes to create programs for Greenfoot. Greenfoot API  provides the classes to create programs for Greenfoot. Java 3D API  provides the classes you need to create 3D objects Java 3D API  provides the classes you need to create 3D objects

Don’t Get Confused! API API –Application Programming Interface –A bunch of classes all bundled together! Think of it as a library of classes that are available for you to use! IDE IDE –Integrated Development Environment –A program that let’s you write programs. –For example, you write Java programs in Netbeans (which is an IDE). SDK SDK –Software Development Kit –Contains a bunch of class libraries, and usually includes an API or two. For example, the Java SDK comes with the Standard Java API. –Sometimes the Software Development Kits come with IDEs included.