English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Urgent! Please help! This project is due soon and I can't continue until I know this! I'm trying to use an abstract class (SongComparator) like so:

SongComparator comparator = new SongComparator();
playlist_1. sort(comparator);

But the first line comes up with this error message: SongComparator is abstract; cannot be instantiated. But if I don't use the first line of code, the variable comparator is never defined. Please help. How do I use these?

2007-12-06 07:04:22 · 1 answers · asked by wildbluefaerie 2 in Computers & Internet Programming & Design

1 answers

An abstract class cannot be directly instantiated. You'll need to create a subclass, and then instantiate that.

class YourSongComparator extends SongComparator {
...
}

2007-12-06 07:53:23 · answer #1 · answered by daa 7 · 0 0

fedest.com, questions and answers