Integer.valueOf
takes in String
and int
as arguments but when I pass Character
, it doesn't require casting and compiler doesn't enforce anything.
Character doesn't extend String
class, it just implements Serializable
and Comparable
Character charc = '1';
System.out.println(Integer.valueOf(charc));
System.out.println(Integer.valueOf(charc.toString()));
output:
49
1
Isn't it kind of design flaw or I am thinking in the wrong direction? Please write the reason in comments when you down-vote it.