Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 Application Programming Interfaces

2 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.

3 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

4 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

5 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.

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

7 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)

8 Videos: Videos: –Google Earth API –API Explanation

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

10 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

11 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.


Download ppt "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."

Similar presentations


Ads by Google