![]() ![]() ![]() Since overrides are determined entirely by name and parameter signature, a class cannot directly provide more than one implementation. This limitation is a byproduct of the way Java overrides methods: If a class method's name and parameter signatures match those of a base class's or interface's method, the class method will override the base's method. That support is limited, though it provides only one way for a class to directly implement an interface. Java offers direct interface support through the interface keyword, which we'll use to write the ICSVColumn interface. Satisfied that our design correctly obeys the rule of interface, we choose our language and move on to code. The structure is represented in the figure on the right. Each column in the contact list maps to a different piece of contact information, so each is associated with a different instance of the ICSVColumn interface. ![]() We can design our program as two separate classes: one that parses comma-separated value (CSV) files in general, and one that records the application-specific contact list.Īs the parser consumes the raw data file, it passes each value to the contact list via the ICSVColumn interface. Suppose, for example, we want to write an application that displays a contact list, which it reads from a comma-delimited text file. This won't, however, stop a creative coder from doing his or her job. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |