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
If a string is null, doesn't isEmpty() throw a Nullpointerexception when used?
Shouldnt we check for isEmpty OR ==null? At least thats how I remember it... But i might be worng.
Harry James14,780 Points
I can totally see where you're coming from here! We still don't actually have a need for checking null because when we run
getText(), if there is no text, we are just given an empty String
"". We'll never actually be returned
null from this method.
Hope this explains things but if there's still something you don't quite understand, give me a shout :)