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 trialDaniel Cadwell
400 PointsWhy am I getting the following error: if (bestSport instanceof String && bestSport == sports[0])
I am trying to access data that is in a String Array and assign it to a String Variable. my code looks like this: String V1 = V2[0]; and I keep getting this error: if (bestSport instanceof String && bestSport == sports[0])
String[] sports = { "Basketball", "Baseball", "Tennis" };
Daniel Cadwell
400 PointsThanks Jordon; I thought so it has to be on the sites end because that is what I have been trying and keep getting the big Bummer. I am a senior at cSU monterrey Bay in computer science....just plowing through these to do a project in android studio which I have never used,,,
Daniel Cadwell
400 PointsThanks Jordon; I thought so it has to be on the sites end because that is what I have been trying and keep getting the big Bummer. I am a senior at cSU monterrey Bay in computer science....just plowing through these to do a project in android studio which I have never used,,,
1 Answer
raajiabraham
2,609 PointsString[] sports = { "Basketball", "Baseball", "Tennis" }; String bestSport = sports[0]; int numberOfSports = sports.length; String lastSport = sports[sports.length-1];
Jordan Ernst
5,121 PointsJordan Ernst
5,121 Pointshey friend i hope this code will help you out: to access the data in the string array you need to remember that each element is referred to by it's place value. ie. (1st=0, 2nd=1, 3rd=2) in the question it asks you to declare bestSport as a string and assign it to the value of the first elemnt in the array. -----> String bestSport= sports[0];