Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Practice Java Arrays!
You have completed Practice Java Arrays!
Preview
Let's see about creating an Array!
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
. Now that you've
0:09
learned about arrays in Java,
it's time for some more practice.
0:10
In this session, you'll be getting
practice with arrays and for loops.
0:14
Let's look through what you'll need to do
to complete the challenge.
0:18
Attached to this video is a new workspace.
0:21
Inside are a couple of files to help
you get started.
0:24
You may recognize Cow.java
from a previous practice
0:28
session,
but this practice session is about arrays.
0:31
So let's click over to the arrays.java
and see what we need to do.
0:34
Start
by creating an array of good cow names.
0:40
This should be a string array
and can be whatever names you'd like.
0:43
After that, create an array of cows
0:47
that's the same length
as your names array.
0:49
Next, use a for loop to populate the cows
0:53
array with cows using names from the names
array.
0:56
And finally, use an enhanced for loop
1:00
to print the name of each cow
from the cows array in step two.
1:03
So, at the end, when we run the program,
1:09
we should see
a name of each of the cows in the list.
1:12
I'll do so by clearing the console,
compiling your project,
1:16
and finally
running it with a Java command.
1:21
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up