foreword
When brushing the question, I encountered such a code:
int cities = isConnected.length;
boolean[] visited = new boolean[cities];
There are doubts about when new Boolean(str) returns false and when it returns true. I found out that a big guy made a summary:
Returns true when the incoming parameter ignores case and is equal to "true" , otherwise returns false.
source code
public static boolean parseBoolean(String s){
return ((s != null) && s.equalsIgnoreCase("true");
}
public Boolean(String s){
this(parseBoolean(s));
}
public Boolean (boolean value){
this.value = value;
}
Several common methods
Use Boolean.valueOf(boolean value) to represent new Boolean(boolean value) because it is more efficient
to get the package type:
Boolean.valueOf(boolean value)
Boolean.valueOf(String s)
Methods for obtaining basic types:
Boolean.pareseBoolean(String s);
new Boolean().booleanValue();
Summarize
Returns true when the incoming parameter ignores case and is equal to "true", otherwise returns false.
Reposted from: When does java utility method series new Boolean(str) return true or false_Jiang Xiaobai's Blog-CSDN Blog