# Mixins as an alternative to inheritance in Java 8

DevFeed: [Mixins as an alternative to inheritance in Java 8](<https://devfeed.tech/articles/mixins-as-an-alternative-to-inheritance-in-java-8-25448.md>)

Original publisher: [Read original article](<https://hannesdorfmann.com/android/java-mixins/>)

Author: Hannes Dorfmann

Published: 2016-04-26T09:00:00Z

Content type: tutorial

Language: en

Sources: [Hannes Dorfmann](<https://devfeed.tech/sources/hannes-dorfmann.md>)

Topics: [Java](<https://devfeed.tech/topics/java.md>), [interfaces](<https://devfeed.tech/topics/interfaces.md>), [Ruby](<https://devfeed.tech/topics/ruby.md>), [Scala](<https://devfeed.tech/topics/scala.md>), [Polymorphism](<https://devfeed.tech/topics/polymorphism.md>)

Tags: [inheritance](<https://devfeed.tech/tags/inheritance.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [java](<https://devfeed.tech/tags/java.md>), [java-8](<https://devfeed.tech/tags/java-8.md>), [programming](<https://devfeed.tech/tags/programming.md>), [programming-language](<https://devfeed.tech/tags/programming-language.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [scala](<https://devfeed.tech/tags/scala.md>)

## AI overview

This tutorial explains how Java 8 default methods in interfaces can be used to compose reusable behavior as mixins, providing an alternative to inheritance. It contrasts this approach with delegation and with mixins or traits in Ruby and Scala.

## Source excerpt

Starting in Android N Google has added some java 8 language features. One of those features is the ability to add default methods to interfaces. Surprisingly (since java 8 has already been released 2 years ago) I haven't found good articles describing the advantage of default methods for interfaces: Mixins!