first commit

This commit is contained in:
Boris
2024-01-15 20:14:10 +00:00
commit 8c81ee28b7
3106 changed files with 474415 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
## Lecture 1 (11:00)
### Flexible-Size Collections
Do not need to specify a size when we create a collection.
Add as many items without concern for space.
### ArrayList
- Imported from java.util
-
### ArrayList Methods
- get()
- remove()
## Lecture 2 (14:00)
### For Each Loop
```java
for( Animal animal : animalCollection )
{
System.out.println(animal)
}
```
- The scope of `animal` is exclusively local to this loop body
- `animal` is of the type Animal
- For each element of type Animal in the `animalCollection` array list
- Not good for searches.
### While Loop
```java
public void showAllAnimals()
{
int listPosition = 0;
while( listPosition < 6 )
{
showAnimal( listPosition );
listPosition++;
}
}
```
### Sentinel
```java
public boolean findAnimal( String myPet ) {
int listPosition = 0;
boolean found = false;
while( listPosition < animalCollection.size() && found == false ) {
Animal animal = animalCollection.get( listPosition );
String name = animal.getName();
if( name.equals( myPet ) ) {
found = true;
}
else {
listPosition++;
}
}
if( found == true ) {
return true
}
else {
return false
}
}
```