File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Missing constructor that accepts a String in class Character

 
Andy James
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the other wrapper classes (Byte, Short, Integer, Long, Double, Float, Boolean) define a constructor that accepts a String argument. Was there a specific reason why it wasn't defined for the class Character?

Thanks.

cheers
Andy
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do we need a String argument parameter to Character class Constructor? Instead of putting a double(") quotas in the Constructor, you can put a single(') quotas! This may be the reason!
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Was there a specific reason why it wasn't defined for the class Character?


If I pass in a String, which is a CharSequence of characters, as the input, which one of these characters should the resulting Character Object represent ? Should an exception be thrown when the String length is greater than 1 character ? Would that be the expected behavior ?

 
Andy James
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abimaran,
Thanks for the reply.

Deepak,
You ask a good set of questions in answer to a single question:
which one of these characters should the resulting Character Object represent ? Should an exception be thrown when the String length is greater than 1 character ? Would that be the expected behavior ?


I apologize if my thought seem to be rude. It seemed that you were irritated while answering this question, as if it seemed quite obvious to you. Examine the source code of the Java API (or for that matter any API) and you will be able to find loads of examples, where code is redundant or seems to be offering functionality that could have been avoided easily.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I apologize if my thought seem to be rude. It seemed that you were irritated while answering this question, as if it seemed quite obvious to you.


haha ! Not at all. Your question was interesting. The way I would have handled it is to not provide a constructor since the expected behavior might be confusing. But thats just me.

The reason I raised those questions was to put seeds of thought into your mind. Your answers, if they can be justified technically, might well prove me wrong. So the questions are mutually beneficial to you, me and the community at large.

Please feel free to ask as many questions in JR as you see fit. We have a 'Be nice' policy that everyone will follow when they answer your questions.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic