Week 9 - Week 10

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

1/24

encourage image

There are no tags or description

Looks like no tags are added yet.

25 Terms

1
New cards

Loop Structures

They are a fundamental concept in programming that allows developers to execute a block of code repeatedly based on a given condition. They are useful when you need to iterate.

2
New cards

Simple For Loop

This is the most commonly used loop structures in java. It is particularly useful when the number of iterations is known before entering the loop.

3
New cards

Simple For Loop

This is structured to handle the initialization of a variable, the condition that controls how the long the loop runs, and the increment or decrement of the loop variable in one line.

4
New cards

For-Each Loop

This is also known as the enhanced for loop. This is a special type of loop introduced in Java 5.

5
New cards

For-Each Loop

This simplifies the process of iterating over arrays and collections by eliminating the need to manage an index or counter variable.

6
New cards

For-Each Loop

This is useful when you want to perform operations on each element of an array or collection without worrying about the loops control structure.

7
New cards

;

In java, you can make a for loop without initialization and increment/ decrement. What symbol do you use to indicate this?

8
New cards

While Loop

This is onfe of the fundamental loop structures in Java, used to repeatedly execute a block of code as long as a specified condition evaluates to true.

9
New cards

While Loop

This is often used when the number of iterations is not predetermined and depends on dynamic conditions during runtime.

10
New cards

While Loop

This is a loop where the condition is evaluated before the loop body is executed, if the condition is false initially- the loop body may not execute at all.

11
New cards

Do-While Loop

This is another fundamental looping structure that allows a block of code to be executed at least once before the condition is tested.  This ensures the body is executed at least once, regardless if its true or false

12
New cards

Do-While Loop

The condition is only evaluated after the loop body, this is an exit controlled loop.

13
New cards

Do-While Loop

This kind of loop will always execute at least once, even if the condition is initially false. 

14
New cards

Break

This is used to exit a loop prematurely, regardless of the loop’s condition.

15
New cards

Break

This is a powerful control structure that allows you to interrupt the normal flow of the loop and immediately transfer control to the statement following the loop. This is useful when you want to terminate on a condition during execution.

16
New cards

Continue

This is used to skip the current iteration of a loop and proceed to the next iteration.

17
New cards

Continue

This only interrupts the current iteration, which allows the loop to continue running as usual. This can be useful when certain conditions require to skip specific steps.

18
New cards

Comments

These are an essential part of writing clean, understandable, and maintainable code.

19
New cards

Comments

They are non-executable lines of text in a program that the compiler ignores, meaning they do not affect the program's behavior. They are primarily used to describe what the code does, explain the purpose of certain variables or blocks of code, and provide additional context for anyone reading the code.

20
New cards

Single-Line Comments

They begin with // and extend to the end of a line. They are used for brief remarks or explanations directly above or beside a line of code.

21
New cards

Multi-Line Comments

Starts with a /* and ends with a */. They are used for longer comments that span multiple lines, making them suitable for explaining complex logic or providing detailed descriptions.

22
New cards

Documentation Comments

This is also known as Javadoc comments, they start with /** and end with */. These comments are used to generate documentation for the code. They are above classes, methods, and fields to describe their purpose, parameter and return values.

23
New cards

Documentation

They are used here to provide descriptions of the class and add method.

24
New cards

Nested Loop

They are an essential concept as they allow the execution of a loop inside another loop. This structure is useful when dealing with multi-dimensional data structures, such as matrices or when doing repeated actions.

25
New cards

Nested For Loops

This is typically used to handle more complex situations, such as generating patterns, performing repetitive calculations, or managing multi-level iterations.