Asked • 03/15/19

Check whether a string is not null and not empty?

How can I check whether a string is not null and not empty? public void doStuff(String str) { if (str != null && str != "**here I want to check the 'str' is empty or not**") { /* handle empty string */ } }

2 Answers By Expert Tutors

By:

Matt R. answered • 03/27/19

Tutor
5.0 (557)

Java Developer

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.