Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKevin Lombardi
2,977 PointsDeclaring and integer
The instructions are to declare an integer numberOfFrogs and to then set it to the number of elements in the array using the length property. I cannot figure this one out. I've tried rewatching the video multiple times.
3 Answers
Gunjeet Hattar
14,483 PointsLets break this and see
first declare an integer variable called numberOfFrogs
Next if you watch the video carefully the use of length property has been shown. It gives you the number of elements inside the array. So in case of frogNames that would be 3 i.e. He, Be and Te
Now the value of 3 will be assigned to the integer variable numberOfFrogs using the length property of arrays
String [] frogNames = {"He", "Be", "Te"};
String bestFrog = frogNames[0];
int numberOfFrogs = frogNames.length;
Hope that helps.
Kevin Lombardi
2,977 PointsThanks! I thought I did that but I probably had a typo in my syntax. Thanks for your assistance.
Kevin Lombardi
2,977 PointsIt worked. I don't know what I was doing. Thank you again.
Gunjeet Hattar
14,483 PointsGreat! You'r welcome