Loops
Arrays
ArrayLists
Reading Text Files
Recursion
100

Make a for loop that stops when i=5, printing i at each iteration

for(int i=0; i=5; i++){

System.out.println(i);

}

100

How do you find the size of array students

students.length

100

How do you find the length of arraylist students

students.Size()

100

What java class is used to read the text file?

Scanner class

File class

100

What is recursion?

Calling a function from inside a function?

200

Name 3 loops in java

for, for-each, while, do-while

and more!

200

How do you change the variable at index 3, to the number 10 in array numbers?

numbers[3] = 10;

200

How do you change the variable at index 3, to the number 10 in arraylist numbers

numbers.set(3,10);

200

Write the statement for declaring a file from a file path using the file path "./bands.txt"

File file = new File("./bands.txt");

200

What is the part of a recursive statement that stops doesn't call the function called?

The base case

300

How would you write an infinite for loop

so many answers

300

Declare an array names with the names Billy and Bob

String[] names = {"billy", "Bob"};

300

Declare an arraylist names and add billy and bob

ArrayList<String> names = new ArrayList<>();

names.add("Billy");        

names.add("Bob");

300

Write the line for the scanner to read in the file path with the file name f

Scanner scnr = new Scanner(f)

300

What is the general structur of a recursive function

public int recursiveFunction(int n){

 if - base case

 else - returns recursiveFunction again modifying n
}

400

How can you use a loop to find the maximum value in an array?

int max = 0;

for(int i=0; i<nums.length; i++){

   if(nums[i] > max) max = nums[i];

}

400

Declare an array students with a size of 5

String[] students = new String[5];

400

Delcare an arraylist students with a size of 5

Arraylist<String> students = new Arraylist<>(5);

400

How do you grab the next line of a text file using scanner

scnr.nextLine();

400

Describe a base case in recursion. Why is it necessary?

Tells the recursive function when to stop calling itself. It prevents infinite loops.

500

How do you iterate through a 2d array using loops?

Concider 2d array seating

Nested for loops!

for(int i =0; i<seating.length;i++){

   for(int j=0; j<seating[i].lengthj++){

        sop(seating[i][j];

 }

}

500

Use the java class Arrays to copy students to the new array of strings kids

String[] kids = Arrays.copyOf(students, students.length);

500

Use the Arraylist method to copy students to an ARRAY of strings kids

String[] kids = students.toArray();

500

How would you split the file text into an array by a comma?

sc.useDelimiter(",");

500

Provide an example of a simple recursive method that computes factorial of a number.

static int factorial(int n)  { 

   if (n == 0) return 1; 

        return n * factorial(n - 1); 

    }

M
e
n
u