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

Java Java Arrays Gotchas and Wins Array Usage in Method Declarations

Why are we getting an error for System.out.printf/ln?

In the if statement, instead of "return" I wrote "System.out.println" and it gives me an IllegalArgumentException: bound must be positive. Why are we getting this kind of error?

please post your code here

Chris Tvedt
Chris Tvedt
3,795 Points

If you are talking about the if-statment in the pickLunchSpot-method, you have to return a String, as the method expect a string return. You can use system.out.println too, but you have to return a string at the end. Else you need to change the return type of the method to be void instead of String.

1 Answer

use "\n" for a new line, System.out.print("\n"); or System.out.println();

also the printf expects an argument for each placeholder string