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 trialConner Mack
7,309 Pointsi need help on this one
help with challenge task 1 of 1 java arrays
public class TeachersExample {
public String[] getTeachersInArrayLongForm() {
String[] teachers = new String[3];
teachers[0] = "Jay";
teachers[1] = "Dave";
teachers[2] = "James";
return teachers;
}
public String[] getTeachersAsArrayLiteral() {
// TODO: Replace null with an array literal that matches the long form above
String[] teachers = new String = ["Jay";"Dave";"James"];
return teachers;
}
}
1 Answer
Aananya Vyas
20,157 PointsIt's simple (Watch the video again for reference if you haven't understood) Here's what you need to pass the challenge though,
public class TeachersExample {
public String[] getTeachersInArrayLongForm() {
String[] teachers = new String[3];
teachers[0] = "Jay";
teachers[1] = "Dave";
teachers[2] = "James";
return teachers;
}
public String[] getTeachersAsArrayLiteral() {
// TODO: Replace null with an array literal that matches the long form above
String[] teachers = new String[] {"Jay" , "Dave" , "James"};
return teachers;
}
}
Hope it helps!
Aananya Vyas
20,157 PointsAananya Vyas
20,157 Pointsone - you are using two equal signs in a single statement here..
String[] teachers = new String = ["Jay";"Dave";"James"];
and second- You are using ';' instead of ',' to seperate entries of arrays..