1/13
Looks like no tags are added yet.
String methods
length(), indexOf(), subString(), subString( , )
String Immutability
Once a String object is created, its value cannot be changed.
substring(int beginIndex, int endIndex)
Returns a new string from the start index up to, but not including, the end index.
indexOf(String str)
Returns the index of the first occurrence of str, or -1 if not found.
Math.random()
Returns a double value greater than or equal to 0.0 and less than 1.0.
Random integer formula (low to high)
(int)(Math.random() * (high - low + 1)) + low
Math.abs(x)
Returns the absolute value of x, can be int or double
Defined Constants (final)
Variables declared with 'final' whose values cannot be changed after initialization.
Constant Naming Convention
Written in all uppercase letters with words separated by underscores (e.g., MAX_VALUE).
static keyword
Indicates that a variable or method belongs to the class itself, rather than to a specific object instance.
Static method restriction
Static methods cannot access non-static instance variables or use the 'this' keyword.
Math.sqrt(x)
Returns the square root of x (non negative), is always double
Math.min(a,b)
Returns the smaller of a and b, two int or two double
Math.max(a,b)
Returns the greater of a and b, two int or two double