Skip to main content

String constructor which accepts CharSequence argument

No replies
aleck_agakhan
Offline
Joined: 2010-12-20
Points: 0

Isn't that a good idea to add the constructor to the class String which can create a string instance from CharSequence? Currently, it is possible to create string from the object which implements the interface CharSequence but the solution requires the use of intermediary char array or StringBuilder. It would kill two birds with one stone: a string instance could be created from any object which implements the interface CharSequence in one line of code, and it would also avoid superfluous allocation of memory for intermediary array with further copying data to and from that array.