{"id":347,"date":"2018-01-24T15:02:43","date_gmt":"2018-01-24T12:02:43","guid":{"rendered":"http:\/\/melic.com\/wp1\/?p=347"},"modified":"2018-01-24T15:03:21","modified_gmt":"2018-01-24T12:03:21","slug":"javada-interfaces-nedir","status":"publish","type":"post","link":"https:\/\/melic.com\/wp1\/javada-interfaces-nedir\/","title":{"rendered":"Java&#8217;da Interfaces Nedir?"},"content":{"rendered":"<p>Ba\u015fl\u0131kta da dedi\u011fi gibi, Interface(arabirim) Java dilinde nesneleri d\u00fcnyaya sunman\u0131n bir yolu.<\/p>\n<p>S\u0131n\u0131flar(class) ile interface aras\u0131ndaki fark s\u0131n\u0131flar\u0131n i\u00e7inde t\u00fcm metotlar (method) i\u00e7in bir uyarlama\/uygulama(implementation) gerekiyorken bir interface  i\u00e7in tan\u0131mlama yapman\u0131z yeterli olacak ve sonra davran\u0131\u015f bi\u00e7imini belirlemek ad\u0131na di\u011fer s\u0131n\u0131flar i\u00e7erisinde tan\u0131mlaman\u0131z yeterli olacakt\u0131r.Kar\u0131\u015f\u0131k g\u00f6r\u00fcnd\u00fc\u011f\u00fcne yada anlatamad\u0131\u011f\u0131ma bakmay\u0131n a\u015fa\u011f\u0131da verece\u011fim \u00f6rnekler ile s\u0131k\u0131nt\u0131 olmadan &#8220;yaaa !! bumuymu\u015f&#8221; k\u0131vam\u0131na gelece\u011fiz.<\/p>\n<p>\u00d6ncelikle size bir s\u0131n\u0131f \u00f6rne\u011fi verece\u011fim :<\/p>\n<blockquote><p>\npublic class Araba{<br \/>\n&nbsp;&nbsp;private String model;<br \/>\n&nbsp;&nbsp;public void calistir(){<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(model +<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&#8221; \u00e7al\u0131\u015f\u0131r!&#8221;);<br \/>\n}<\/p><\/blockquote>\n<p>Bu da bir interface ve bir s\u0131n\u0131f i\u00e7erisindeki yap\u0131land\u0131r\u0131lmas\u0131:<\/p>\n<blockquote><p>\npublic interface Araba{<br \/>\n&nbsp;&nbsp;public void calistir(){}<br \/>\n&nbsp;&nbsp;public void durdur(int hiz){}<br \/>\n}<\/p>\n<p>public class AileArabasi implements Araba{<br \/>\n&nbsp;&nbsp;private String model;<br \/>\n&nbsp;&nbsp;public AileArabasi(String yeniModel){<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;model = yeniModel<br \/>\n  }<br \/>\n  public void calistir(){<br \/>\n&nbsp;&nbsp;System.out.println(model +&#8221; \u00e7al\u0131\u015f\u0131r!&#8221;);<br \/>\n  }<br \/>\n  public void stop(int hiz){<br \/>\n&nbsp;&nbsp;if(hiz < 30){\nEven though both Car and Boat interfaces would have the start() method, it wouldn't do anything anyway, so there is no problem in choosing the right one to use in each case. This is the advantage interfaces have over super classes.\n&nbsp;&nbsp;System.out.println(model +\n&nbsp;&nbsp;\" yava\u015f\u00e7a durur!\");\n  }  \n}<\/p><\/blockquote>\n<p>Genel bir interface Java&#8217;da genellikle L\u0130ST ile kullan\u0131l\u0131r.Bunun ba\u015fl\u0131ca sebebi hem konsepte uygun olmas\u0131 hemde bir \u00e7ok \u015fekilde uygulanabilirli\u011fidir (ArrayList,LinkedList, vesaire). Interface olmalar\u0131 gayet anlaml\u0131&#8230;<\/p>\n<p>Biz normalde bir list&#8217;in ne yapt\u0131\u011f\u0131n\u0131 biliyoruz,ve bizde bu \u015fekilde datay\u0131 interface \u00fczerine at\u0131yoruz.Listler ile nas\u0131l yap\u0131l\u0131r derseniz o list tipine g\u00f6re de\u011fi\u015fir : node ya da array kullanman\u0131za g\u00f6re yani.<\/p>\n<p>Even though both Car and Boat interfaces would have the start() method, it wouldn&#8217;t do anything anyway, so there is no problem in choosing the right one to use in each case. This is the advantage interfaces have over super classes.<\/p>\n<p>Bir interface bir s\u0131n\u0131f\u0131n kendisini kendi i\u00e7inde uygulamas\u0131na\/uyarlamas\u0131na ba\u011fl\u0131 olarak<br \/>\nBir interface, onu uygulayan s\u0131n\u0131flar\u0131n, \u00f6rne\u011fin Arabalar olarak nitelendirilebilecek y\u00f6ntemleri sa\u011flar; ancak ayn\u0131 zamanda, bir Araba s\u0131n\u0131f\u0131n\u0131 geni\u015fleten her \u015feyi miras almak \u00fczere s\u0131n\u0131rland\u0131r\u0131lmalar\u0131 anlam\u0131na da gelmez.<\/p>\n<p>\u00c7\u00fcnk\u00fc bir interface sadece bir model ile gelir, bir s\u0131n\u0131f tek bir s\u0131n\u0131f\u0131 geni\u015fletmek yerine,  ne kadar interface&#8217;e ihtiya\u00e7 duyuyorsa o kadar interface tan\u0131mlayabilir\/kullanabilir (implement), <\/p>\n<blockquote><p>public class YuzerArac implements Araba, Tekne{<br \/>\n&nbsp;&nbsp;public void calistir(){<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;   &#8230;<br \/>\n&nbsp;&nbsp; }<br \/>\n}<\/p><\/blockquote>\n<p>\u00d6rnekte g\u00f6r\u00fcld\u00fc\u011f\u00fc \u00fczere hem Araba hemde Tekne intrefacelerinin calistir() metotlar\u0131 mevcut, <\/p>\n<p>Her iki Araba ve Tekne interfaceleri (aray\u00fczleri) start () metoduna (y\u00f6ntem) sahip olsa da, her durumda bir i\u015flem yapmaz, bu nedenle her durumda kullan\u0131lacak do\u011fru olan\u0131 se\u00e7erken sorun olmaz. Bu, interfacelerin (arabirim) s\u00fcper s\u0131n\u0131flar \u00fczerinde sahip olduklar\u0131 avantajd\u0131r.<\/p>\n<p>Umar\u0131m anla\u015f\u0131lm\u0131\u015ft\u0131r, keza bence \u00f6rnek a\u00e7\u0131klamadan daha anla\u015f\u0131l\u0131r oldu ama a\u00e7\u0131klamaya kalk\u0131nca maalesef biraz karma\u015f\u0131k g\u00f6z\u00fck\u00fcyor. Kod okur yazarl\u0131\u011f\u0131 iyi bir \u015fey i\u015fte; \u00e7\u00fcnk\u00fc bazen ister istemez okudu\u011fumuz bir s\u00fcr\u00fc terim sebebiyle<br \/>\nEven though both Car and Boat interfaces would have the start() method, it wouldn&#8217;t do anything anyway, so there is no problem in choosing the right one to use in each case. This is the advantage interfaces have over super classes. anla\u015f\u0131l\u0131r olmaktan \u00e7\u0131k\u0131yor.Bu da yaz\u0131l\u0131m d\u00fcnyas\u0131n\u0131n ba\u015fka bir ger\u00e7e\u011fi. Ne demek istedi\u011fimi anlamak i\u00e7in WYSIWYG ne demek bilmek laz\u0131m :D <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ba\u015fl\u0131kta da dedi\u011fi gibi, Interface(arabirim) Java dilinde nesneleri d\u00fcnyaya sunman\u0131n bir yolu. S\u0131n\u0131flar(class) ile interface aras\u0131ndaki fark s\u0131n\u0131flar\u0131n i\u00e7inde t\u00fcm metotlar (method) i\u00e7in bir uyarlama\/uygulama(implementation) gerekiyorken bir interface i\u00e7in tan\u0131mlama yapman\u0131z yeterli olacak ve sonra davran\u0131\u015f bi\u00e7imini belirlemek ad\u0131na di\u011fer s\u0131n\u0131flar i\u00e7erisinde tan\u0131mlaman\u0131z yeterli olacakt\u0131r.Kar\u0131\u015f\u0131k g\u00f6r\u00fcnd\u00fc\u011f\u00fcne yada anlatamad\u0131\u011f\u0131ma bakmay\u0131n a\u015fa\u011f\u0131da&#8230;<\/p>\n","protected":false},"author":1,"featured_media":322,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[89],"tags":[83,140,141,138,65,144,145,143,142,139],"class_list":["post-347","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-class","tag-implementation","tag-implements","tag-interface","tag-java","tag-method","tag-methods","tag-model","tag-modeling","tag-super-class"],"_links":{"self":[{"href":"https:\/\/melic.com\/wp1\/wp-json\/wp\/v2\/posts\/347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/melic.com\/wp1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/melic.com\/wp1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/melic.com\/wp1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/melic.com\/wp1\/wp-json\/wp\/v2\/comments?post=347"}],"version-history":[{"count":6,"href":"https:\/\/melic.com\/wp1\/wp-json\/wp\/v2\/posts\/347\/revisions"}],"predecessor-version":[{"id":449,"href":"https:\/\/melic.com\/wp1\/wp-json\/wp\/v2\/posts\/347\/revisions\/449"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/melic.com\/wp1\/wp-json\/wp\/v2\/media\/322"}],"wp:attachment":[{"href":"https:\/\/melic.com\/wp1\/wp-json\/wp\/v2\/media?parent=347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/melic.com\/wp1\/wp-json\/wp\/v2\/categories?post=347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/melic.com\/wp1\/wp-json\/wp\/v2\/tags?post=347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}