Java API specifications, class Character, class String
The goal of this module is to:
- Get you to practice looking at the Java API (Application Programmer Interface) specifications of Java classes;
- Introduce you to class Character;
- Introduce you to class String;
Goal 1 is important. Java comes with many classes that you can use in Java programs, but you can learn about them and use them only if you have some skill in accessing the API specs of a class, in reading its general explanation, and in looking through its methods to find out what is available. Gaining a skill in this now will help you immensely later in the course and afterward.
The Java API documentation
Java has predefined classes for all sorts of things from dealing with strings of characters to building GUIS to reading web pages. Because there are so many classes, they are grouped into "packages". The documentation for all these classes appears on the web as the "Java API Specification". This video shows you how to visit the JAVA API Spec in a browser and how to read it. (2:49 minutes) Read it here: 01API.pdf
The API specification for class Character
We use the spec for class Character to show you the various sections of an API spec and show you how to navigate around it. When you are finished, bring up the spec for class Character in your favorite browser and become familiar with the methods listed below. This will help you later, when you need to use them in a program you are writing. (5:50 minutes) Read it here: 02Character.pdf
instance | charValue() | compareTo(Character c); | equals(Object obj) | |
static | compare(char x, char y) | |||
isDigit(char ch) | isLetter(char ch) | isLetterOrDigit(char ch) | ||
isJavaIdentifierPart(char ch) | isJavaIdentifierStart(char ch) | |||
isLowerCase(char ch) | isUpperCase(char ch) | |||
isSpaceChar(char ch) | isWhitespace(char ch) | |||
toLowerCase(char ch) | toUpperCase(char ch) | toString() | ||
Class String
We discuss important aspects about class String, including how a String is implemented. We ask you to spend some time looking at the API specs of the String methods shown below (many of the functions are overloaded, and we just give their names). Then, we develop a short function that manipulates a string in order to talk about the development process. (5:30 minutes) Read it here: 03String.pdf
instance | length | charAt; | substring | |
indexOf | lastIndexOf | |||
startsWith | endsWith | contains | ||
compareTo | equal | |||
trim | replace | |||
toLowerCase | toUpperCase | |||
static | valueOf | |||