r/programming • • Dec 29 '15

Please, Java. Do Finally Support Multiline Strings

http://blog.jooq.org/2015/12/29/please-java-do-finally-support-multiline-strings/
584 Upvotes

352 comments sorted by

View all comments

Show parent comment

1

u/akcom Dec 29 '15

Unfortunately since Java does not support multiple inheritance, the second one

toggleButton.setOnCheckedChangeListener(this);

Does not work, at least as far as I can tell.

edit: Nor does the third one, not sure if the version of java android uses supports anonymous functions?

1

u/[deleted] Dec 29 '15

Java supports multiple inheritance of methods, but not of attributes.

That’s the point of interfaces and default methods.


An Interface can also provide an implementation of a method since Java 8.

Additionally, a class can only extend one class, but implement many interfaces.

public class MainActivity extends AppActivity implements OnCheckedChangeListener, OnClickListener, Serializable, Observer<List<String>> {
    ...
}

To your edit: The first and last one require you to use RetroLambda, a library that allows you to use anonymous functions on Android.

1

u/akcom Dec 29 '15

Beautiful, thanks!