Skip to content

Commit 2f07967

Browse files
author
zhourenjian
committed
Fixed a bug of error results on
(new Character('c')).equals('c') Thanks sgurin for reporting this bug.
1 parent 29de03b commit 2f07967

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

sources/net.sf.j2s.java.core/src/java/lang/Character.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,30 @@ public char charValue() {
107107
return value;
108108
}
109109

110+
/**
111+
* Returns a hash code for this <code>Character</code>.
112+
* @return a hash code value for this object.
113+
*/
114+
public int hashCode() {
115+
return (int)value;
116+
}
117+
118+
/**
119+
* Compares this object against the specified object.
120+
* The result is <code>true</code> if and only if the argument is not
121+
* <code>null</code> and is a <code>Character</code> object that
122+
* represents the same <code>char</code> value as this object.
123+
*
124+
* @param obj the object to compare with.
125+
* @return <code>true</code> if the objects are the same;
126+
* <code>false</code> otherwise.
127+
*/
128+
public boolean equals(Object obj) {
129+
if (obj instanceof Character) {
130+
return value == ((Character)obj).charValue();
131+
}
132+
return false;
133+
}
110134

111135
/**
112136
* Compares the receiver to the specified Character to determine the

0 commit comments

Comments
 (0)