Using the Java APIWhere’s the API?OverviewGeneral approachThe Packages panelThe Classes panelThe links barThe main information areaReading the method descriptions IReading the method descriptions IIHow was this documentation produced?Value of the APIWhere to find the API docsThe EndJan 14, 2019Using the Java APIhttp://java.sun.com/javase/6/docs/api/2Where’s the API?3OverviewClassesMain Information AreaViewsPackages4General approachIf you know the name of the package, click it in the upper left panel; or click All ClassesClick on the class in the lower left panelScroll in the right pane to find the summary of the field, method, or constructor you wantOr just read the general descriptionFor more information, click the link in the summary to go to the detailed information5The Packages panelChoose the package you are interested inOr, choose All ClassesClasses in java.lang are automatically imported into every program--you don’t have to do it yourselfOld snapshots—but the format hasn’t changed6The Classes panelThis panel shows both classes and interfacesWe haven’t yet talked about interfacesNote that some classes have names similar to primitive types (Boolean, Byte, Character)7The links barOverview is where you start outIndex is handy for looking up methodsHelp is the obviousIf you don’t like frames, you can chooseNO FRAMESDeprecated methods are those that have been replaced by better methods and should not be used8The main information areaGeneral description of the classField summaryConstructor summaryMethod summaryField detailConstructor detailMethod detailIn each case, the “summary” is the first sentence of the “detail”9Reading the method descriptions IAn example from the String class:public char charAt(int index)Returns the character at the specified indexpublic means accessible from anywherechar is the return typecharAt is the name of the methodint is the type of parameter expectedindex is just a suggestive nameExample use: char firstChar = myStr.charAt(0);10Reading the method descriptions IIAnother example from the String class:public static String valueOf(int i)Returns the string representation of the int argument. public means accessible from anywherestatic means this is a class method (see use below)String is the return type, and is a hyperlinkvalueOf is the name of the methodint is the type of parameter expectedi is just a suggestive nameExample use: String numeral = String.valueOf(m / n);11How was this documentation produced?All Java documentation was produced by the javadoc program from javadoc (or just doc) comments in the source codeYour doc comments can be used in the same way to produce professional-looking documentationThe Interface menu item in BlueJ does the same basic thing as javadocLike most things in BlueJ, fancy features have been omitted in the interests of simplicity12Value of the APIVersion packages classes methods Java 1.0 8 212 1545 Java 1.1 23 504 3851 Java 1.2 60 1781 15060 Java 1.3 77 2130 17158 Java 1.4 135 2738 ? Java 1.5 and 6 ? ? ?You can only learn a small fraction of theseWhen 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 programmerA good craftsman knows his/her tools13Where to find the API docsOn the web:http://java.sun.com/javase/6/docs/api/On your own computer (if you downloaded them):C:/ProgramFiles/Java/jdk1.6.0_01/docs/api/index.html14The
View Full Document