Added a toString method similar to AbstractCollection's.
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8940 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
817591076e
commit
4c2ccc66e0
@ -320,6 +320,25 @@ public class SafeArrayList<E> implements List<E> {
|
|||||||
return Collections.unmodifiableList(raw);
|
return Collections.unmodifiableList(raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
|
||||||
|
E[] array = getArray();
|
||||||
|
if( array.length == 0 ) {
|
||||||
|
return "[]";
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append('[');
|
||||||
|
for( int i = 0; i < array.length; i++ ) {
|
||||||
|
if( i > 0 )
|
||||||
|
sb.append( ", " );
|
||||||
|
E e = array[i];
|
||||||
|
sb.append( e == this ? "(this Collection)" : e );
|
||||||
|
}
|
||||||
|
sb.append(']');
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
protected class ArrayIterator<E> implements ListIterator<E> {
|
protected class ArrayIterator<E> implements ListIterator<E> {
|
||||||
private E[] array;
|
private E[] array;
|
||||||
private int next;
|
private int next;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user