From f9562fcb6f75c093c100fa30b2adc01cb331aa50 Mon Sep 17 00:00:00 2001 From: Toyin277 <40902265+Toyin277@users.noreply.github.com> Date: Mon, 16 Jul 2018 16:25:57 -0500 Subject: [PATCH] Updated Birds --- Review2.java | 44 +++++++++++--------------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/Review2.java b/Review2.java index 14fa7ec..d04f1fe 100644 --- a/Review2.java +++ b/Review2.java @@ -1,11 +1,10 @@ -/* +/* _____ ____ ___ ____ ___ _ ___ | ____/ ___|_ _| |___ \ / _ \/ |( _ ) | _| \___ \| | __) | | | | |/ _ \ | |___ ___) | | / __/| |_| | | (_) | |_____|____/___| |_____|\___/|_|\___/ - */ //If you are lost, do not be afraid to ask for help or look back on previous assignments. @@ -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]); - } } }