3rd Six Weeks Flashcards
Math methods
- Math.ceil( ): The Math.ceil(x) function returns the smallest integer greater than or equal to a number “x”.
- Math.floor( ): The Math.floor(x) function returns the largest integer less than or equal to a number “x”.
- Math.round( ): The Math.round() function returns the value of a number rounded to the nearest integer.
- Math.min( ): The min() method returns the number with the lowest value.
- Math.max( ): The max() method returns the number with the highest value.
- Math.sqrt( ): The sqrt() method returns the square root of a number
- Math.pow( ): The pow() method returns the value of x to the power of y (xy).
String class
s1. equals( “hi”)
s1. substring(5)
s1. substring( 2,7)
s1. charAt(3)
s1. indexOf(“a”)
Scanner methods
next( ) nextInt( ): when working with an integer nextDouble( ): when working with a double nextLine( ) hasNext( )
The next() and hasNext() methods and their primitive-type companion methods (such as nextInt() and hasNextInt()) first skip any input that matches the delimiter pattern, and then attempt to return the next token. Both hasNext and next methods may block waiting for further input. Whether a hasNext method blocks has no connection to whether or not its associated next method will block.
while loop
A while loop is a control structure that allows you to repeat a task a certain number of times.
do…while loop
A do…while loop is similar to a while loop, except that a do…while loop is guaranteed to execute at least one time.
for Loop
A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times.
A for loop is useful when you know how many times a task is to be repeated.