60 likes | 177 Views
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010. Java API. “ And you guys were putting Java in light bulbs and everything else. ” --Steve Jobs.
E N D
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Java API “ And you guys were putting Java in light bulbs and everything else. ” --Steve Jobs Course Lecture Slides7 June 2010 Ganesh Viswanathan
Java Library • Oracle (earlier Sun) ships hundreds of pre-built classes • This set of classes is called the Java library or the Java API
Packages • Classes are grouped into packages • Packages are hierarchical • you can have packages within packages. • Example • java.lang.Math indicates that Math is a class in the package lang and that lang is a package in the package java.
Using a class from Java API • Find out which package the class is in • Put an import statement at the top of your source code file • Example: import java.util.Arrays; import java.util.*; • Now you can use the class and its methods • If you do not have the import statement, you can still use the class, but every time you will have to qualify the class name with the package information. • For example, java.util.Arrays.sort(…)
Knowing about Java API • How do you know what classes are there in Java API or methods are there in a class in Java API • Go to : • Click on the package name and then the class name to know about what that class can do for you http://java.sun.com/javase/6/docs/api/index.html