File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes String doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "String doubt" Watch "String doubt" New topic

String doubt

John P Joseph

Joined: May 14, 2005
Posts: 11
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

Joined: Jan 09, 2006
Posts: 66
You can't reduce the array length by removing an array element. length is public final member of Array.

Thanks,<br />Murali...
vandu matcha
Ranch Hand

Joined: Dec 28, 2005
Posts: 57
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

Joined: Oct 12, 2004
Posts: 306

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.
I agree. Here's the link:
subject: String doubt
It's not a secret anymore!