AP Java: Strings, Math, Constants & Static

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/13

encourage image

There's no tags or description

Looks like no tags are added yet.

14 Terms

1
New cards

String methods

length(), indexOf(), subString(), subString( , )

2
New cards

String Immutability

Once a String object is created, its value cannot be changed.

3
New cards

substring(int beginIndex, int endIndex)

Returns a new string from the start index up to, but not including, the end index.

4
New cards

indexOf(String str)

Returns the index of the first occurrence of str, or -1 if not found.

5
New cards

Math.random()

Returns a double value greater than or equal to 0.0 and less than 1.0.

6
New cards

Random integer formula (low to high)

(int)(Math.random() * (high - low + 1)) + low

7
New cards

Math.abs(x)

Returns the absolute value of x, can be int or double

8
New cards

Defined Constants (final)

Variables declared with 'final' whose values cannot be changed after initialization.

9
New cards

Constant Naming Convention

Written in all uppercase letters with words separated by underscores (e.g., MAX_VALUE).

10
New cards

static keyword

Indicates that a variable or method belongs to the class itself, rather than to a specific object instance.

11
New cards

Static method restriction

Static methods cannot access non-static instance variables or use the 'this' keyword.

12
New cards

Math.sqrt(x)

Returns the square root of x (non negative), is always double

13
New cards

Math.min(a,b)

Returns the smaller of a and b, two int or two double

14
New cards

Math.max(a,b)

Returns the greater of a and b, two int or two double