Skip to main content
Filter by
Sorted by
Tagged with
0 votes
2 answers
109 views

@FunctionalInterface interface StringConsumer extends Consumer<String> { @Override public default void accept(String s) { System.out.println(s.toUpperCase()); } void ...
Alper ARSLAN's user avatar
1 vote
1 answer
272 views

I'm getting the following error while implementing the java.util.Iterator interface in my class: java: MenuIterator is not abstract and does not override abstract method remove() in java.util.Iterator....
Aleksandar Zizovic's user avatar
2 votes
0 answers
60 views

When instantiating a class that has code to explicitly call a default method for an interface that it implements, a java.lang.VerifyError is thrown. This happens on Kitkat (API 19), but Lollipop and ...
ewittman's user avatar
0 votes
1 answer
356 views

I am a beginner in Java. I have a question about the abstract method in Interface. Is the following sampleMethod() an abstract method? My understanding is that it is not an abstract method due to ...
Lei's user avatar
  • 11
5 votes
0 answers
46 views

I don't understand why an IllegalAccessError exception is thrown from the example below. The method foo() in Parent cannot be inherited by Child, because it is private. But trying to call the default ...
Andrey's user avatar
  • 59
5 votes
2 answers
308 views

What is the point of making Functor a super class of Applicative and Monad. Both Applicative and Monad immediately imply the only implementation of Functor that abides by the laws as far as I can tell....
HashBr0wn 's user avatar
0 votes
1 answer
396 views

You often hear that methods in an interface have no implementation. However, in Java 8 it became possible to implement the default methods. But I'm interested. Was and is it possible to implement ...
stfxc's user avatar
  • 174
0 votes
0 answers
94 views

interface WithDefinitionsInter { default void definedMeth() { System.out.println("inside interface"); } } class WithDefinitionsImpl implements WithDefinitionsInter { ...
Manish Bansal's user avatar
2 votes
1 answer
661 views

I have gone through a number of posts, but all seem to answer that where are the static methods of an interface stored. However, an interface can have abstract, static and default methods. I know ...
Ashish's user avatar
  • 1,932
4 votes
0 answers
125 views

Consider the code below. interface I { default Number f() { return 0; } } class A { private Number f() { // if Number is replaced with other type, all will work fine ...
Ruslan Shikhov's user avatar
4 votes
2 answers
167 views

I was thinking of proposing a feature request to add default methods called: default boolean greaterThan(T o) { return compareTo(o) > 0; } default boolean smallerThan(T o) { return ...
Maarten Bodewes's user avatar
21 votes
3 answers
16k views

I am trying to add logging to my interface default method. For example: @Slf4j // not allowed interface MyIFace { default ThickAndThin doThisAndThat() { log.error("default ...
pirho's user avatar
  • 12.4k
-1 votes
1 answer
143 views

I tried to add one VBA project Lib as reference for a second VBA project App and the default class members don't work. Is this a limitation of VBA? Or is there something I need to do to get it to work?...
stenci's user avatar
  • 8,559
3 votes
2 answers
512 views

I would like to ask for an advise. I am learning C# and I am always trying to reduce code duplication and I am struggling to find "best practice" in C#. I am trying to use Default interface ...
walter33's user avatar
  • 1,050
9 votes
2 answers
820 views

I have an interface that inherits from Android's TextWatcher to only implement afterTextChanged method. I have enabled Java 8 support in my project, and added source and target compatibility options ...
M. Samil Atesoglu's user avatar
2 votes
1 answer
294 views

I want to make an interface with default implementation for equality and comparison functions. If I remove everything from the type IKeyable<'A> except the Key member, it is a valid interface, ...
Jean Lopes's user avatar
1 vote
1 answer
352 views

I am trying to define default method implementations, but only if the class's type variables derive certain other classes. I have tried creating type-dependent instances using => (am I even using ...
Solomon Ucko's user avatar
  • 6,190
3 votes
1 answer
112 views

I am learning the Java 8 syntax and came across a piece of code in our application below in an interface: default EmployeeEnricher employeeEnricher() { return builder -> { return; ...
user1318369's user avatar
0 votes
0 answers
641 views

I want to provide default implementation for method in my Kotlin interface: interface INavItem : Comparable<INavItem> { val order: Int @JvmDefault override fun compareTo(other: ...
Sergei Bubenshchikov's user avatar
-3 votes
2 answers
425 views

Interface: public interface SomeInt{ Integer getX(); void setX(Integer value); default Integer getY(){ return getX(); } default void setY(Integer value){ setX(value); } ...
brallow's user avatar
  • 49
1 vote
2 answers
87 views

This code crashes: public class MyClass { public static void main(String args[]) { Person person = new Person(); person.selectMe(); } } class Entity {} interface EntityNameable&...
J. Doe's user avatar
  • 13.5k
4 votes
2 answers
236 views

This questions is the same as this one with a twist. I have an interface such as : @Repository public interface InvoiceRepository extends JpaRepository<Invoice, String>{ // some other ...
Orkun's user avatar
  • 7,338
0 votes
4 answers
2k views

For a while I have been puzzled as to why we need default methods in Interfaces, and today I was reading about it. Even though few of my questions are answered, I still have a few queries. Let's take ...
Logan's user avatar
  • 2,545
6 votes
2 answers
4k views

Since multiple inheritance is not allowed in java/kotlin, it's usefull to take advantage of interface default methods. Given example: abstract class Animal { fun beAnimal() { println("I'...
xinaiz's user avatar
  • 7,798
2 votes
2 answers
459 views

As much i know interface provides full abstraction because it can't have any concrete method like abstract class. But from java 8, interfaces can have concrete methods using default keyword and the ...
SbrTa's user avatar
  • 158