The Artima Developer Community
Sponsored Link

Java Buzz Forum
What is the actual use of interface in Java?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Javin Paul

Posts: 1090
Nickname: javinpaul
Registered: Jan, 2012

Javin Paul is Java Programmer working on Finance domain.
What is the actual use of interface in Java? Posted: Feb 18, 2014 8:34 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Javin Paul.
Original Post: What is the actual use of interface in Java?
Feed Title: Java67
Feed URL: http://www.java67.com/feeds/posts/default?alt=rss
Feed Description: Java and technology tutorials, tips, questions for all programmers.
Latest Java Buzz Posts
Latest Java Buzz Posts by Javin Paul
Latest Posts From Java67

Advertisement
Interface in Java has remains a complex topic for many beginners to understand. First thing which puzzles many programmers is the fact that you cannot define any method inside interface, it just declaration. By rule, all method inside interface must be abstract (Well, this rule is changing in Java 8 to allow lambda expressions, now interface can have one non abstract method, also known as default method). So, if you can't define anything, Why we need interface?  what's the use of interface, if we are anyway going to write a class and override them to provide behaviour, Can't we declare those methods inside class itself without using interface etc. Well, if you are thinking in terms of behaviour than you are really missing the point of interface. I think one has to read Effective Java, to understand best use of interface. Interface is great to declare Type, they promote code reusability, and they are the real driver of polymorphism in Java. Interface also allows multiple inheritance in Java, which makes it possible for a class to become Canvas, as well as EventListener, which is used to draw graphics as well as to to process events. In this post, I will share few points, which will help you to understand what is the actual use of interface in Java. By the way, if you are confused between abstract class and interface, then you may want to read my previous post on difference between interface and abstract class in Java
Read more »

Read: What is the actual use of interface in Java?

Topic: Cost of Delay Due to Multitasking, Part 2 Previous Topic   Next Topic Topic: My advice to (junior) developers about their career

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use