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 trialzlatkap
21,494 PointsI have got a problem with forEach loop
Looks like I miss something. The error is "illegal character", "; expected".. but I cannot see where :/
IntStream.range(0, 100).forEach(i -> {
String template = templates[i % templates.length];
String buzzword = buzzwords[i % buzzwords.length];
String title = String.format(template, buzzword);
Course c = new Course(title, "http://www.example.com");
Review review = new Review((i % 5) + 1, String.format("Moar %s please!!!", buzzword));
review.setReviewer(students.get(i % students.size()));
c.addReview(review);
bunchOfCourses.add(c);
});
zlatkap
21,494 PointsSOLVED!
3 Answers
Alexander Davison
65,469 PointsUse =>
instead of ->
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsI think this is Java not JavaScript
zlatkap
21,494 PointsYes, this is Java, not Javascript. Programming Java API in Spring. This is the course and video: https://teamtreehouse.com/library/populating-and-relationships
zlatkap
21,494 PointsFor some reason, this was IDE problem or something. I deleted part "forEach(i -> {" and wrote it again and everything works perfectly.
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsBrendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsA few things would help: