This week's book giveaways are in the iOS and Features new in Java 8 forums. We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line! See this thread and this one for details.
Marker interfaces (or tagging interfaces, as they are normally known) are basically used to "signal" something to the users of your classes. You would better understand with an example. Consider the method :
Now, this method may either recieve a LinkedList or it may recieve an ArrayList, or even some new List type that you are not even aware of! You never know with what type of a List this method will be called. However, you want to make sure that your sorter() method is as optimized as possible. How would you do this?
You might be aware that there is a tagging interface in the collections library called RandomAccess. The ArrayList implements this interface. Why? Its just to signal that random access for that particular container is going to be efficient. Random access in an ArrayList is efficient and the same on a LinkedList is definitely not. So, you can use this tag to your advantage in your sorter() method and modify the method as follows:
Does this make the concept clear?
Vijayendra <br /> <br />"The harder you train in peace, the lesser you bleed in war"