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!
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
Nicolas Hampton44,638 Points
Automatic throw in Example.java
I noticed that we didn't have to write a throw into the Example.java to throw the exception. Is that because the Exception errors are already built into these classes that we didn't have to build? Hope I'm phrasing this correctly.
Victor Learned6,976 Points
Yes the compiler will throw run time exceptions automatically. You only manually throw exceptions when you intend to handler them. A good example of this is when working with files. If you intend to read a file typically you'll either check to ensure the file exists then do some action or just try to do the action and then catch the NoSuchFile (not the precise name but you get the point) exception that is thrown.
Michael C3,230 Points
We'll actually you don't need to throw an Exception at all. But as you said - there are automatically thrown Exceptions in C#.NET actually, so you might be right - I think it's the same for Java in a common or maybe just a particular case.