Glossary
APIs
Application Programming Interfaces are sets of rules and definitions that allow different software components to communicate with each other. They define the methods and data structures that applications can use to interact with a library or service.
Example:
When you use System.out.println(), you're interacting with the Java Standard Library's API for printing output to the console, without needing to know the internal workings of how it prints.
Character
A single letter, number, symbol, or space that makes up a string. In Java, it's often represented by the `char` primitive type or as a substring of length 1.
Example:
In the word 'hello', 'h' is the first character, 'e' is the second, and so on.
External Libraries
Collections of pre-written code that extend Java's built-in capabilities, providing ready-to-use functionalities for common programming tasks.
Example:
Instead of writing complex code to handle dates and times, you might use an external library like Joda-Time to simplify date calculations, making your code cleaner and more efficient. This saves you from having to write all the date-handling logic from scratch, allowing you to focus on your application's unique features.
Java Documentation
Official reference material for Java classes, libraries, and APIs, detailing available methods, their parameters, return types, and descriptions of their functionality.
Example:
Before using a new method, a smart programmer always checks the Java Documentation to understand its exact behavior and any potential edge cases, like what happens if you pass a null value.
String Class
A fundamental class in Java (`java.lang.String`) used to represent sequences of characters. String objects are immutable, meaning their value cannot be changed after creation.
Example:
When you declare String name = "Alice";, you are creating an instance of the String Class to store the text 'Alice'.
Substring
A contiguous sequence of characters within a larger string. It can be a single character or a longer segment.
Example:
From the string 'programming', 'gram' is a substring that starts at index 3 and ends before index 7.
Zero-Indexed Language
A programming language where the first element in a sequence (like a string or array) is located at index 0, rather than 1.
Example:
Because Java is a zero-indexed language, the first character of the string 'Java' is at index 0, not index 1.
compareTo() Method
A String method that lexicographically compares two strings (based on Unicode values). It returns a negative integer if the calling string comes before the argument string, zero if they are equal, and a positive integer if it comes after.
Example:
If you compare "apple".compareTo("banana"), the compareTo() method will return a negative number because 'apple' comes before 'banana' alphabetically.
equals() Method
A String method that compares two strings to determine if they contain the exact same sequence of characters, case-sensitively. It returns `true` if they are identical, `false` otherwise.
Example:
While "Hello" == "Hello" might be true due to string pooling, "Hello".equals("hello") would return false because the equals() method performs a case-sensitive comparison.
indexOf() Method
A String method that returns the index within the calling string of the first occurrence of the specified substring. If the substring is not found, it returns -1.
Example:
For String sentence = "The quick brown fox";, sentence.indexOf("quick") would return 4, as 'q' is at index 4. If you searched for 'zebra', it would return -1 because 'zebra' is not in the sentence.
length() Method
A String method that returns the number of characters in the string. It is commonly used to determine the size of a string.
Example:
If String word = "computer";, then word.length() would return 8, indicating there are 8 characters in the word.
substring() Method
A String method used to extract a portion of a string. It can take one argument (start index to end of string) or two arguments (start index to end index, exclusive).
Example:
Given String phrase = "AP Computer Science";, phrase.substring(3, 11) would return 'Computer', extracting the characters from index 3 up to (but not including) index 11.