Java Coding Practice

Enter your name and class period to start your session.

{ }

Certificate of Completion

0
Problems solved
0
Topics covered
0m
Time practicing
Problems completed
Java
Easy
Problem
Your solution
Test results
AP Computer Science A — Java Quick Reference
2026 Exam Reference Sheet
String class
Method / ConstructorDescription
String(String str)Constructs a new String representing the same characters as str
int length()Returns the number of characters
String substring(int from, int to)Returns substring from index from up to (not including) to
String substring(int from)Returns substring(from, length())
int indexOf(String str)Returns index of first occurrence of str; -1 if not found
boolean equals(Object other)Returns true if same character sequence as other
int compareTo(String other)Returns <0, 0, or >0 based on alphabetical ordering
String[] split(String del)Splits the string around matches of del; returns a String array
Integer class
Method / FieldDescription
Integer.MIN_VALUEThe minimum value representable by an int
Integer.MAX_VALUEThe maximum value representable by an int
static int parseInt(String s)Returns the String argument as an int
Double class
MethodDescription
static double parseDouble(String s)Returns the String argument as a double
Math class
MethodDescription
static int abs(int x)Returns the absolute value of an int
static double abs(double x)Returns the absolute value of a double
static double pow(double base, double exponent)Returns base raised to the power of exponent
static double sqrt(double x)Returns the nonnegative square root of x
static double random()Returns a random double where 0.0 <= value < 1.0
ArrayList class
MethodDescription
int size()Returns the number of elements in the list
boolean add(E obj)Appends obj to end of list; returns true
void add(int index, E obj)Inserts obj at position index, shifting elements right
E get(int index)Returns the element at position index
E set(int index, E obj)Replaces element at index with obj; returns the old element
E remove(int index)Removes element at index, shifting elements left; returns the removed element
Object class
MethodDescription
boolean equals(Object other)Returns true if this object is equal to other
String toString()Returns a string representation of this object
File class
ConstructorDescription
File(String pathname)Constructs a File object from the given pathname string
Scanner class
Method / ConstructorDescription
Scanner(File f)Constructs a Scanner that reads from the given File
int nextInt()Returns the next int from the input; throws InputMismatchException if unavailable or out of range
double nextDouble()Returns the next double from the input; throws InputMismatchException if unavailable
boolean nextBoolean()Returns the next boolean from the input; throws InputMismatchException if unavailable
String nextLine()Returns the next line of text as a String; may return empty string if called immediately after another Scanner method
String next()Returns the next token (whitespace-delimited) as a String
boolean hasNext()Returns true if there is another token to read; false otherwise
void close()Closes this scanner