• Post Reply Bookmark Topic Watch Topic
  • New Topic

final class with protected data  RSS feed

 
Ravi Danum
Ranch Hand
Posts: 154
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Does it make sense to have a final class that has protected data.

public final class MyClass
{
protected Set<String> mySet;

....
}

I am working with some code like this.

Thanks for any help.

-ravi
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, there's no point in that, since "protected" is meant specifically to allow subclasses into the "inner circle", but a final class cannot have any subclasses.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree. Either make them private, or give them package visibility (remove the protected modifier) if you need other classes in the same package to have access to them.
 
Ravi Danum
Ranch Hand
Posts: 154
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! -ravi
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!