1 00:00:00,230 --> 00:00:02,690 All right, did you figure it out? 2 00:00:02,690 --> 00:00:04,260 Here's my solution. 3 00:00:04,260 --> 00:00:07,980 First, we need to create an array of good cow names. 4 00:00:07,980 --> 00:00:13,420 So I'll start by creating a new string array called names. 5 00:00:13,420 --> 00:00:16,530 And setting it equal to a few names that I like. 6 00:00:16,530 --> 00:00:20,310 Remember, to create an array literal we can use the brackets and 7 00:00:20,310 --> 00:00:21,530 add the names in the middle. 8 00:00:22,730 --> 00:00:28,537 I'll go with Larry, 9 00:00:28,537 --> 00:00:34,840 Zelda, and Myrtle. 10 00:00:34,840 --> 00:00:36,070 Awesome, next, 11 00:00:36,070 --> 00:00:41,324 we need to create an array of cows that's the same length as our names array. 12 00:00:41,324 --> 00:00:47,290 So create an array of cows called cows and 13 00:00:47,290 --> 00:00:50,806 set it equal to new Cow. 14 00:00:50,806 --> 00:00:55,920 Then we need to pass in an argument for how long the array is. 15 00:00:55,920 --> 00:01:02,780 We could just type in 3 but we can also type in names.length. 16 00:01:02,780 --> 00:01:06,970 Next, we need to use a for loop to populate our new cows array 17 00:01:08,190 --> 00:01:13,910 with new cows using the names from the names array. 18 00:01:13,910 --> 00:01:19,040 Let's start by just creating a for loop, 19 00:01:19,040 --> 00:01:27,410 for int i = 0, and we'll loop while i is less than names.length. 20 00:01:27,410 --> 00:01:34,961 We could also use 3 or cows.length, if we wanted to. 21 00:01:34,961 --> 00:01:41,331 Then we need to increment i by 1 and add the body of our for loop with brackets. 22 00:01:41,331 --> 00:01:46,421 Inside the for loop, we need to set cows 23 00:01:46,421 --> 00:01:51,975 at position i equal to a new Cow with the name 24 00:01:51,975 --> 00:01:58,795 from the names array at the ith position, perfect. 25 00:01:58,795 --> 00:02:00,845 Finally, we want to use an enhanced for 26 00:02:00,845 --> 00:02:04,395 loop or foreach loop to print the name of each cow. 27 00:02:05,650 --> 00:02:10,486 For Cow and we'll name it cow. 28 00:02:10,486 --> 00:02:17,371 So a cow in the cows array, and for each cow in the cows array, 29 00:02:17,371 --> 00:02:21,560 let's print out the name of the cow. 30 00:02:21,560 --> 00:02:25,400 So we'll do console.printf. 31 00:02:25,400 --> 00:02:30,340 Then we'll use %s for our placeholder and %n to add a new line. 32 00:02:31,870 --> 00:02:38,078 Then we need to fill in our placeholder with cow.getName to retrieve the name. 33 00:02:38,078 --> 00:02:39,863 And semi colon to finish it off. 34 00:02:39,863 --> 00:02:43,490 And last but not least, we just need to run it. 35 00:02:44,730 --> 00:02:46,510 Write a command to clear the workspace. 36 00:02:49,721 --> 00:02:53,058 Compile our arrays.java. 37 00:02:55,584 --> 00:02:57,580 And run it using the java command. 38 00:03:03,068 --> 00:03:08,200 And there we go, we've got cows named Larry, Zelda, and Myrtle.