August 2001
Intermediate to advanced
480 pages
9h 14m
English
An advantage of separation of interface and implementation is that you can provide different implementations to the same interface. Let's see how we can provide another implementation of the DictionaryService interface in our dictionary bundle.
The following implementation class returns word definitions from Webster's dictionary:
package com.acme.impl.dictionary; import java.util.*; import com.acme.service.dictionary.DictionaryService; class Webster implements DictionaryService { private Properties defs; Webster() { defs = new Properties(); defs.put("accuse", "to charge with a fault or offense"); defs.put("admire", "to marvel at or esteem highly"); defs.put("calamity", "a state of deep distress ...Read now
Unlock full access