@peterdrake Sure that technically works. But why teach students bad practices and the wrong way of doing it when you could teach them the right way (with exceptions). It really isnt a difficult topic and is kinda fundamental to java.
@freemo Another issue is that some techniques (e.g., making fields private and having public getters and setters) only pay off for larger programs. I strive to introduce things just at the point where they are obviously useful.
That said, maybe this is a golden opportunity to introduce exceptions...
@freemo (1) "really isn't a difficult topic" is relative. It's good Java practice to never put anything in the default package, but they certainly can't handle that when they're still figuring out what an object is. (Don't worry, they learn about exceptions before they graduate.) Choosing the right time to introduce things, especially when there's a wide range of levels of preparation in a class, is always a struggle.
(2) Student limitations aside, are exceptions the best choice? People on Twitter have also suggested an enum, an Optional, constants, or the empty String to avoid having a null lying around. What's the cleanest way to go?