The basic problem of Java wrapper class Boolean construction method Boolean (String s) ()

description:
Boolean (String s), if the String parameter is not null and equals "true" when case is ignored, create a Boolean object that represents the true value, such as Boolean b = new Boolean ("ok"), which is false.
-
in Boolean b = new Boolean ("ok"), isn"t the value of b true? Is the above description contradictory

< hr >
Aug.03,2021

clipboard.png
is still false. Just take a look at the source code. Only in the case of "true" is true,. All the others are false:

.
 public static boolean parseBoolean(String s) {
        return ((s != null) && s.equalsIgnoreCase("true"));
    }

Let's start with the conclusion: false

public Boolean(String s) {
   this(parseBoolean(s));
}

will first call parseBoolean , and then call another constructor method:

public Boolean(boolean value) {
   this.value = value;
}

well, let's take a look at parseBoolean Code:

public static boolean parseBoolean(String s) {
   return ((s != null) && s.equalsIgnoreCase("true"));
}

so unless the constructor parameter is "TRUE" or "true" or TRue , the result will all be false , including "ok" the string

.

is equal to "true" when case is ignored, where true is a quoted string

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf7350-313b8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf7350-313b8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?