{"action":"created","issue":{"url":"https://api.github.com/repos/winterbe/java8-tutorial/issues/7","labels_url":"https://api.github.com/repos/winterbe/java8-tutorial/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/winterbe/java8-tutorial/issues/7/comments","events_url":"https://api.github.com/repos/winterbe/java8-tutorial/issues/7/events","html_url":"https://github.com/winterbe/java8-tutorial/issues/7","id":116634721,"number":7,"title":"\"Extension Methods\"","user":{"login":"spencerwi","id":2829379,"avatar_url":"https://avatars.githubusercontent.com/u/2829379?v=3","gravatar_id":"","url":"https://api.github.com/users/spencerwi","html_url":"https://github.com/spencerwi","followers_url":"https://api.github.com/users/spencerwi/followers","following_url":"https://api.github.com/users/spencerwi/following{/other_user}","gists_url":"https://api.github.com/users/spencerwi/gists{/gist_id}","starred_url":"https://api.github.com/users/spencerwi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spencerwi/subscriptions","organizations_url":"https://api.github.com/users/spencerwi/orgs","repos_url":"https://api.github.com/users/spencerwi/repos","events_url":"https://api.github.com/users/spencerwi/events{/privacy}","received_events_url":"https://api.github.com/users/spencerwi/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-12T20:36:54Z","updated_at":"2015-11-13T06:49:18Z","closed_at":"2015-11-13T06:49:18Z","body":"From the \"Default Methods for Interfaces\" section:\r\n\r\n>Java 8 enables us to add non-abstract method implementations to interfaces by utilizing the default keyword. This feature is also known as **Extension Methods.**\r\n\r\nThis is inaccurate; I cannot, for instance, add a method `foo()` to String that could be called like so:\r\n\r\n```java\r\nString something = \"bar\";\r\nsomething.foo();\r\n\"something else\".foo();\r\n```\r\n\r\nDefault methods on interfaces are more analogous to methods inherited from an abstract class than they are to [extension methods](https://en.wikipedia.org/wiki/Extension_method), which are \"[methods] added to an object *after* the original object was compiled\".\r\n\r\nYou can't actually add methods to any given object after it's compiled, because you can't change the interfaces which it declares that it implements. You also can't change an interface after it's compiled, and because of how interfaces work in Java, the interface must be compiled before the class. So if you don't control the class, you necessarily don't control the interface, and so you can't really add methods to any objects of that class after it's compiled."},"comment":{"url":"https://api.github.com/repos/winterbe/java8-tutorial/issues/comments/156341995","html_url":"https://github.com/winterbe/java8-tutorial/issues/7#issuecomment-156341995","issue_url":"https://api.github.com/repos/winterbe/java8-tutorial/issues/7","id":156341995,"user":{"login":"winterbe","id":485033,"avatar_url":"https://avatars.githubusercontent.com/u/485033?v=3","gravatar_id":"","url":"https://api.github.com/users/winterbe","html_url":"https://github.com/winterbe","followers_url":"https://api.github.com/users/winterbe/followers","following_url":"https://api.github.com/users/winterbe/following{/other_user}","gists_url":"https://api.github.com/users/winterbe/gists{/gist_id}","starred_url":"https://api.github.com/users/winterbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/winterbe/subscriptions","organizations_url":"https://api.github.com/users/winterbe/orgs","repos_url":"https://api.github.com/users/winterbe/repos","events_url":"https://api.github.com/users/winterbe/events{/privacy}","received_events_url":"https://api.github.com/users/winterbe/received_events","type":"User","site_admin":false},"created_at":"2015-11-13T06:49:18Z","updated_at":"2015-11-13T06:49:18Z","body":"Couldn't find the cite in the official docs anymore, so maybe they've removed to prevent confusion. However Brian Goetz (Java Language Architect) calls default methods **virtual extension methods**, see: http://stackoverflow.com/a/24102730\r\n\r\nI've corrected the README and put a link for clarifications. Thank you guys for pointing that out! :+1: "}}