0

I'm trying to use ceilingKey(), ceilingEntry(), firstKey() and firstEntry() of the TreeMap class but getting error:
java.lang.NoSuchMethodError: method java.util.TreeMap.firstEntry with signature ()Ljava.util.Map$Entry; was not found.

This error is caused by following code:
if (tmpmap.size() == 1 && tmpmap.firstKey() == req_sbyte && tmpmap.firstEntry().getValue() == req_size) {
send("F" + req_nr + "," + Integer.toString(req_filenr) + "," + Long.toString(req_sbyte) + "," + Integer.toString(req_size), "localhost", CLIENTPORT);
}

This is the output of java -version:
java version "1.5.0" gij (GNU libgcj) version 4.1.2 20070925 (Red Hat 4.1.2-33) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Any explanations why is this happening and how to fix it? I checked libgcj's documentation, and it says there is such method firstEntry() and it returns Entry object which has getValue() method. So I do not clearly understand what is the problem with my code.

1 Answer 1

6

firstEntry() is a Java 1.6 method.

See http://java.sun.com/javase/6/docs/api/java/util/TreeMap.html#firstEntry().

Sign up to request clarification or add additional context in comments.

1 Comment

Yep, it's part of the NavigableMap interface that was added in Java 6.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.