Results 1 to 4 of 4
- 02-13-2011, 02:36 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 8
- Rep Power
- 0
- 02-13-2011, 02:55 PM #2
Because interface can offer other behaver in depend from class realization, You can see on interface List and class ArrayList and other, for example.
Skype: petrarsentev
http://TrackStudio.com
- 02-13-2011, 03:50 PM #3
Senior Member
- Join Date
- Feb 2010
- Location
- Ljubljana, Slovenia
- Posts
- 470
- Rep Power
- 11
To expand, interfaces define behaviour without specifying the details. If you define an interface, you say, any class that implements this interface can do this, this and this. It's also a better alternative to weak superclassing. A weak superclass is one that breakes it's subclasses functionality if altered. Since an interface is just method signatures and constants, this problem is avioded. Also, you can make your code more generic, and thus more open to change. Lets say you're doing something with arraylists, and make a helper method to do something:
Java Code:public void doSomething(ArrayList<Integer> list) { //bla bla bla }
Java Code:public void doSomething(List<Integer> list) { //yak yak }
Ever seen a dog chase its tail? Now that's an infinite loop.
- 02-13-2011, 06:10 PM #4
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,638
- Rep Power
- 13
Similar Threads
-
interface purpose?
By frejon26 in forum New To JavaReplies: 5Last Post: 06-27-2014, 10:41 AM -
purpose of a static methods
By hoosierfan24 in forum New To JavaReplies: 20Last Post: 02-11-2011, 07:58 PM -
Don't understand interfaces for inheritance
By BoomPony in forum New To JavaReplies: 7Last Post: 11-28-2010, 09:23 PM -
Purpose of abstract class
By scott in forum Threads and SynchronizationReplies: 5Last Post: 03-26-2010, 05:21 AM -
Over-riding purpose fails..
By udayadas in forum New To JavaReplies: 7Last Post: 08-24-2008, 05:14 AM
Bookmarks