Reputation: 37
i have source code call as PhpArray Class from JavaBridge
public final class PhpArray extends AbstractMap
{
private TreeMap t;
private HashMap m;
public PhpArray() {
this.t = new TreeMap(Request.PHP_ARRAY_KEY_COMPARATOR);
this.m = null;
}
@Override
public Object put(final Object key, final Object value) {
if (this.m != null) {
return this.m.put(key, value);
}
try {
return this.t.put(key, value);
}
catch (ClassCastException e) {
this.m = new HashMap(this.t);
this.t = null;
return this.m.put(key, value);
}
}
@Override
public Set entrySet() {
if (this.t != null) {
return this.t.entrySet();
}
return this.m.entrySet();
}
public int arraySize() {
if (this.t == null) {
throw new IllegalArgumentException("The passed PHP \"array\" is not a sequence but a dictionary");
}
if (this.t.size() == 0) {
return 0;
}
return 1 + this.t.lastKey();
}
}
i got an error in this code
public int arraySize() {
if (this.t == null) {
throw new IllegalArgumentException("The passed PHP \"array\" is not a sequence but a dictionary");
}
if (this.t.size() == 0) {
return 0;
}
return 1 + this.t.lastKey();
}
error which i got are
operator + undefined for the arguments type(s) int, object
from my lastKey() we call this methods
public K lastKey() {
return key(getLastEntry());
}
and here for getLastEntry
final Entry<K,V> getLastEntry() {
Entry<K,V> p = root;
if (p != null)
while (p.right != null)
p = p.right;
return p;
}
i want to know how to fix it ? i have try add after TreeMap like this TreeMap<String,String> i got still error. so i want to know how to fix it
from this call i see this is for return int
protected static final IntegerComparator PHP_ARRAY_KEY_COMPARATOR;
after i change my code as like this return 1 + (Integer)this.t.lastKey(); this code not get error again... i want to know suggestion from this forum is it ok for this code ?
Upvotes: 0
Views: 135