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

System.out.print vs illegalArgumentExpression

I understand that the illegalArgumentExpression is used to show that the input is incorrect, but why can't we just use System.out.print to tell the user that they already guessed the letter? Wouldn't this do the same job?

1 Answer

Hi Dylan,

Yes, you could use a standard output warning to prompt the user but that wouldn't teach you about handling exceptions. The use of the IllegalArgumentException is by way of example, showing how exceptions are generated and handled in your code.

Steve.