Skip to content
Advertisement

Tag: interface

access interface out of the class java

I have a class A, another is B, there is one interface Ai with one method ok() only. Class A implements Ai, inside the ok I’m printing just a line. Class B has an instance of A, I want to access A’s …

Java strange class cast exception

Could anyone help me understand why in 1 situation I do not have ClassCastException? At least String::trim is not a MagicFunction. Answer So, method references (like String::trim) are a bit weird; unlike most expressions in Java, they don’t really have a type of their own. Something like this: won’t even compile, because it doesn’t give the compiler enough information about

Is there such a thing as a “local interface” in Java?

Java allows me to define local abstract classes, like in this example: For some reason, when I try to define a “local interface” instead of the local class, like this: Java complains that “The member interface Bar can only be defined inside a top-level class or interface”. Is there a reason for this? Or am I missing a mistake I

Advertisement