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 trialMayur Lalwani
9,074 PointsError in Exception
I am getting following error while compiling Example.java for Pez Dispenser Example in Exception Handling..
Example.java:44: error: no suitable method found for println(String,String)
System.out.println("The error was %s",iae.getMessage());
^
method PrintStream.println() is not applicable
(actual and formal argument lists differ in length)
method PrintStream.println(boolean) is not applicable
(actual and formal argument lists differ in length)
method PrintStream.println(char) is not applicable
(actual and formal argument lists differ in length)
method PrintStream.println(int) is not applicable
1 Answer
Steve Hunter
57,712 PointsHi there,
The println
method can't handle string interpolation - use printf
instead as that allows you to use placeholders and pass in additional strings. The video at 5m14s shows the use of the alternative method.
Steve.
Mayur Lalwani
9,074 PointsMayur Lalwani
9,074 PointsIt worked..Thanks!
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsNo problem!!