Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can you extend the Collections class?  RSS feed

 
Anthony Smith
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
package intltech.autopay.utils;

import java.util.Collections;

public class MyCollection extends Collections
{


}

What can I do to get this to compile?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The class java.util.Collections (with an "s") has a private constructor, so you cannot extend it.

But if you want to define a "MyCollection" class, I think you really mean java.util.Collection (no "s"), which is an interface that you should be able to implement. Better yet, check the API for some abstract classes that already implement this interface. That will at least give you a running start.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!