This may sound really basic. But I'm brand new to Java. With the few initial hours of learning I've put in so far, I'm continuously perplexed by the redundancy in the syntax of a new object declaration:
TypeName a = new TypeName();
In particular,
String s = new String("abc");
Character c = new Character("A");
Why in the world would someone want to type the keyword TypeName
(eg. String
, Character
, etc...) twice? I understand there are short-hands of:
String s = "abc";
char c = "A";
But these are exceptions rather than rules. So can any one enlighten me please? Thx.