Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Purpose of using Interface in projects or within applications  RSS feed

 
Rd Dari
Ranch Hand
Posts: 214
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

We use Interface in our application what is the main purpose of using it? Can we use only sub classes or abstract classes instead of interface?Please explain it.


Thanks in advanced.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question has been ask a LOT before...if you searched, you probably would have already found the answer.

In brief, it lets you be more flexible in how you write code. It shouldn't matter to me if the data is stored as a linked list, a hash table, an array, or something else. All i want to do is getNextElement(). If I write my code to use the interface, I can change the underlying data structure as much as I want, as long as it still implements the interface and has a getNextelement() method.

Search this forum for more posts on this same topic, and you'll find more detail.
 
Rd Dari
Ranch Hand
Posts: 214
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:
Search this forum for more posts on this same topic, and you'll find more detail.

I searched a lot but I did not find here particular topic so please tell me exact motive of using it. Give some real world example if its possible.It will be appreciable.

Thank you!
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I searched a lot but I did not find here particular topic

what about this, this, or this?

 
Rd Dari
Ranch Hand
Posts: 214
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for it.....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!