null value or empty string

Yulia :

I tried to use counter to count the amount of null or empty string. But it always failed. I print them to test it.

System.out.println(samples.get(0).getAuthor2());
System.out.println(samples.get(0).getAuthor2() == " ");
System.out.println(samples.get(0).getAuthor2().isEmpty());
System.out.println(samples.get(0).getAuthor2() == null);

The result is like this. screenshot If these are all false, what is this blank?

Francesco Genta :

To test String you have to use equals method so you have

System.out.println(samples.get(0).getAuthor2().equals(" "));

to be true

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Setting a string to be empty if value is null

MongoDB empty string value vs null value

Add " | " in string if where string value is not null or empty

How to check if a value is not null and not empty string in JS

How return null value to empty string field

Set null as empty string value for input field

Eloquent select rows with empty string or null value

Comparing empty string with null value - SQL Server

Is there a way to replace empty string into NULL value in MariaDB?

Allow null value but not allow empty String in Symfony

Why is the default value of the string type null instead of an empty string?

includeViewParams=true converts null model value to empty string in query string

Group linq results by value and group null or invalid values by empty string

How to show empty string when value is NULL in jQuery on .append() funtion

How to specify an empty string as Target null value in xaml

Replace any object field with value empty string to null without iteration?

How to replace from null value empty string in java?

How to coalesce an empty/null value that is part of Concact string in Postgres?

In YamlDotNet: Is there a way to output a null value as an empty string in a sequence?

PostgreSQL cannot convert empty string to (null) date value

using ?? operator for string null or empty and DBNull.Value

How to get null value instead of empty string with Glass Mapper?

Exclude null or empty string value from lambda expression

MARIADB - Can SQL convert NULL to an empty string if no default value is provided?

Check if a string is not NULL or EMPTY

Empty string vs NULL

How to set non-null string variable's value to empty if null value passed

Replacing null String to empty String

Can my empty TextInput value be sent to the DataProvider as empty string instead of converted to null?