I am a bit inexperienced in programming and may therefore be foolish.
But I have a problem in the following method:
import java.util.Set;
public class Launcher
{
public static void printEntries(ReadableMap<String, Integer> a)
{
Set<String> b = a.keysAsSet();
try
{
for(String i : b)
{
if(i != null)
{
getOrThrow(i);
}
System.out.println(i + ": " + getOrThrow(i));
}
}
catch(UnknownKeyException z)
{
throw new UnknownKeyException();
System.out.println("Eine UnknownKeyException ist aufgetreten.");
}
}
}
The method getOrThrow(String) is undefined for the type Launcher.
Here are some code snippets that might be helpful:
public interface ReadableMap<K, V> {
public abstract V getOrThrow(K key) throws UnknownKeyException;
}
and
public abstract class AbstractReadableMap<K, V> implements ReadableMap<K, V>
{
protected Entry<K, V>[] entries;
public V getOrThrow(K k) throws UnknownKeyException
{
for(Entry<K, V> i : entries)
{
if(i.getValue() != null && i.getKey().equals(k))
{
return i.getValue();
}
}
throw new UnknownKeyException();
}
}
Why is that and how can I fix it?
I am very grateful for any kind of help.
Thank you in advance!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…