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 Objects Harnessing the Power of Objects Exceptions

Mayur Lalwani
Mayur Lalwani
9,074 Points

Error 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

Hi 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.

:+1: No problem!!