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 trialSoumitra Mehrotra
337 PointsWhy didn't we directly used hours[i].setSummary(jsonHour.getString("summary")); ???
In the video , first we wrote Hour[] hours=new Hour[data.length()]; Then,we have declared Hour hour=new hour() ; for each iteration and then, we wrote hour.setSummary(jsonHour.getString("summary")); At last we did hours[i]=hour;
why is that we could have used directly??I tried but the apps stops??
1 Answer
Mohammed Yehia
Courses Plus Student 9,255 PointsYou could use hours[i] but first you need to create an object to hold the data so you should write it like this hours[i] = new Hour(); then you could use hours[i].setSummary(jsonHour.getString("summary")); and at the end its the same it's just reference
Soumitra Mehrotra
337 PointsSoumitra Mehrotra
337 PointsOh ok thanx. I got confused.!!