API Documentation
1. What It Is (beginner)
API docs = official manual for every ready-made Java class/method. Like a dictionary: tells you what a method does, what it takes, what it returns, without reading its code. Lives at docs.oracle.com/javase.
2. How to Read One Entry (example String.length())
Class String — java.lang
int length() — Returns the length of this string.
Returns: number of characters. Example: "Hello".length() → 5
Parts: package (java.lang = auto-imported), signature (int length()), description, params/returns/throws, example + version (Since 1.0).
3. Beginner Workflow with Code
// doubt: how to compare strings ignoring case?
// API → String has: boolean equalsIgnoreCase(String s)
String a = "Java";
System.out.println(a.equalsIgnoreCase("JAVA")); // true — confirmed by docs
Steps: search class → pick method → check params → copy example → test small.
4. Javadoc (write your own docs)
/**
* Adds two numbers.
* @param a first number
* @param b second number
* @return sum of a and b
*/
public int add(int a, int b) { return a + b; }
Run javadoc Demo.java → HTML manual like Oracle's.
5. Exam Points
- What is API docs + how to read signature — 3-5 marks, frequent.
- Javadoc tags
@param @return— 3 marks, frequent. - Name 3 auto-available packages (
java.lang,java.util,java.io) — 2 marks.