Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 11 additions & 33 deletions Review2.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/*

/*
_____ ____ ___ ____ ___ _ ___
| ____/ ___|_ _| |___ \ / _ \/ |( _ )
| _| \___ \| | __) | | | | |/ _ \
| |___ ___) | | / __/| |_| | | (_) |
|_____|____/___| |_____|\___/|_|\___/

*/

//If you are lost, do not be afraid to ask for help or look back on previous assignments.
Expand All @@ -20,52 +19,31 @@ public static void main(String[] args){
type[] var-name;

such as

int intArray[];
or int[] intArray;

BOTH are valid ways to initialize arrays

*/

//Now we're going to create an integer array for a phone number

/*

Each number and space in the array consists with its index
[7][7][3][8][8][6][9][5][9][3]
|0||1||2||3||4||5||6||7||8||9|
*/

int[] phoneNumber;
phoneNumber = new int[10]; //A phone number has 10 digits, BUT every arrays first index is 0 so we have 9 total indexes
phoneNumber[0] = 7;
phoneNumber[1] = 7;
phoneNumber[2] = 3;
phoneNumber[3] = 8;
phoneNumber[4] = 8;
phoneNumber[5] = 6;
phoneNumber[6] = 9;
phoneNumber[7] = 5;
phoneNumber[8] = 9;
phoneNumber[9] = 3;

for (int i = 0; i < phoneNumber.length; i++) {
System.out.println("Element at index " + i + " : "+ phoneNumber[i]);
}


String[] birds;
birds = new String[5]; //A phone number has 10 digits, BUT every arrays first index is 0 so we have 9 total indexes
birds[0] = "penguin";
birds[1] = "BarredOwl";
birds[2] = "BlueJay";
birds[3] = "Woodpecker";
birds[4] = "Chicken";
for (int i = 0; i < birds.length; i++) {
System.out.println("The bird at the " + i + " index is the "+ birds[i]);
}
//EXERCISE: Create a String array called birbs with 5 indexes. In the first index put "cockatiels"







for (int i = 0; i < birbs.length; i++) {
System.out.println("The bird at the " + i + " index is the "+ birbs[i]);
}

}
}