{"id":201,"date":"2009-07-27T22:09:31","date_gmt":"2009-07-27T21:09:31","guid":{"rendered":"http:\/\/www.codingfriends.com\/?p=201"},"modified":"2009-07-27T22:09:31","modified_gmt":"2009-07-27T21:09:31","slug":"interfaces","status":"publish","type":"post","link":"https:\/\/www.codingfriends.com\/index.php\/2009\/07\/27\/interfaces\/","title":{"rendered":"Interfaces"},"content":{"rendered":"<p>An interface describes what functions an implemented class will have to code.  E.g. if a class was a car and the interface had functions for how many doors etc, then a class of  Vauxhall that implements the interface would have to code the function to return the correct amount of doors.  <\/p>\n<p>Here is the code, I usually find the code explains it better.<\/p>\n<pre lang=\"java\">\r\n\/\/ defines the fuctions that have to be implemented by a implementable class\r\ninterface implementThese\r\n{\r\n       void printHi();       \/\/ have to implement these\r\n       void printBye();\r\n}\r\n\r\n\/\/ the interClass will implement the interface implementThese\r\nclass interClass implements implementThese\r\n{\r\n       public void printHi()\r\n       {\r\n              System.out.println(\"Hi\");\r\n       }\r\n\r\n       public void printBye()\r\n       {\r\n              System.out.println(\"Bye\");\r\n       }\r\n}\r\n\r\nclass inter\r\n{\r\n       public static void main(String args[])\r\n       {\r\n              interClass in = new interClass();\r\n              \/\/ call the classes functions.\r\n              in.printHi();\r\n              in.printBye();\r\n       }\r\n}\r\n<\/pre>\n<p>If you save as inter.java, and then run the output will be<\/p>\n<pre class=\"consoleoutput\">\r\nHi\r\nBye\r\n<\/pre>\n<p>There can be many interfaces per class to be implemented.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>An interface describes what functions an implemented class will have to code. E.g. if a class was a car and the interface had functions for how many doors etc, then a class of Vauxhall that implements the interface would have to code the function to return the correct amount of doors. Here is the code, &hellip; <a href=\"https:\/\/www.codingfriends.com\/index.php\/2009\/07\/27\/interfaces\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Interfaces<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[401,398,400],"class_list":["post-201","post","type-post","status-publish","format-standard","hentry","category-java","tag-java","tag-linux","tag-windows"],"_links":{"self":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/comments?post=201"}],"version-history":[{"count":1,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/201\/revisions"}],"predecessor-version":[{"id":202,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/201\/revisions\/202"}],"wp:attachment":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/media?parent=201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/categories?post=201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/tags?post=201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}