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 trial

Android Build a Simple Android App (retired 2014) Learning the Language Introduction to Arrays

Semir Teskeredzic
Semir Teskeredzic
259 Points

Problems initializing arrays

Hello, I am stuck with the 2/4 challenge with arrays. I have to declare a string bestFrog and initialize it to the first element of the array. Heres what Ive typed but I keep getting compiler errors and Ive tried everything I could have thought of. Thank you

String [] frogNames = { "Mike", "Dzemo", "Konjo"}; string bestFrog =""; int bestFrog = frogNames[0];

2 Answers

Ivan Uvarov
Ivan Uvarov
22,403 Points
String bestFrog = frogNames[0];

This is the right code. In your code you created an empty string (String should start with capital letter btw), and later you initialized new variable bestFrog of type integer and assigned to it String value. You cannot do this, you have to create a variable of type String and assign a value of type String to it.

Semir Teskeredzic
Semir Teskeredzic
259 Points

Thank you. Its now clearer when you explained the mess I wrote. Cheers