Skip to content

Commit 1bbb622

Browse files
committed
added README.md for code
1 parent a4154ca commit 1bbb622

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

01-default-static-interface-methods.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ default int remainder(int number, int divisor) {
155155

156156
A class can extend a single class but can implement multiple interfaces. Now that it is feasible to have method implementations in interfaces Java has multiple inheritance of behavior. Java already has multiple inheritance at type level but now it also has multiple inheritance at behavior level. There are three resolution rules that helps decide which method will be picked:
157157

158-
1. Methods declared in classes win over method defined in interfaces.
158+
**Rule 1: Methods declared in classes win over method defined in interfaces.**
159159
```java
160160
interface A {
161161
default void doSth(){
@@ -176,7 +176,8 @@ class App implements A{
176176
```
177177
This will print `inside App` as methods declared in class have precedence over methods declared in interfaces.
178178

179-
1. Otherwise, the most specific interface is selected
179+
**Rule 2: Otherwise, the most specific interface is selected**
180+
180181
```java
181182
interface A {
182183
default void doSth() {
@@ -198,7 +199,8 @@ class App implements C, B, A {
198199
```
199200
This will print `inside C`.
200201

201-
1. Otherwise, class has to call the desired implementation explicitly
202+
**Rule 3: Otherwise, class has to call the desired implementation explicitly**
203+
202204
```java
203205
interface A {
204206
default void doSth() {

code/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Java 8: The Missing Tutorial Supporting Code
2+
-----
3+
4+
This gradle Java 8 project houses example code that is used in the tutorial.
5+
6+
## Table of Contents
7+
8+
* [Default and Static Methods for Interfaces](https://github.com/shekhargulati/java8-the-missing-tutorial/tree/master/code/src/main/java/com/shekhargulati/java8_tutorial/ch01)

0 commit comments

Comments
 (0)