1 / 11

Application Programming Interfaces

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

Download Presentation

Application Programming Interfaces

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Application Programming Interfaces

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

  3. Random class java.util Scanner package class • 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:

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

  5. 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. • 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. • It just tells the compiler that you want to make all the classes in the package available.

  6. 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:

  7. APIs are not specific to Java. • There are APIs for all kinds of things… • 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)

  8. Videos: • Google Earth API • API Explanation

  9. 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. • 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.

  10. Here are a few examples of APIs: • 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. • Java 3D API  provides the classes you need to create 3D objects

  11. Don’t Get Confused! • 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 • Integrated Development Environment • A program that let’s you write programs. • For example, you write Java programs in Netbeans (which is an IDE). • 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.

More Related