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

String doubt

 
John P Joseph
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String[] arr={"a","b","c"}

How to reduce the arr length by 1 by removing the last element without declaring a new array?
 
Murali Mohan
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't reduce the array length by removing an array element. length is public final member of Array.
 
vandu matcha
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String class implements immutable character strings, which are read-only once the string has been created and initialised ...their state cannot be changed...
 
jiju ka
Ranch Hand
Posts: 306
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

String class implements immutable character strings

String is immutable. String keeps an array of characters which is mutable as any other array. But String don't have a method to modify this array and restrict subclassing String class by declaring the class final.

The interface String implements is CharSequence which is not mandating the implementor should be immutable.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic