I know that it's possible to "force" a class to have a certain function through interfaces, but is there any way to "force" a class to have and assign certain variables? Also, is there way to "force" a class to assign inherited variables?
Xeros606
0
Newbie Poster
Recommended Answers
Jump to PostForcing a class to implement abstract methods is not the same as forcing a variable - you can force the class to have the variable via inheritance, but as far as I know you can't force it to initialize it.
Jump to PostYou could put the initialization in the constructor for an abstract class, and hope they call super().
What about declaring a static final in the parent class? Would that do it?
All 5 Replies
apines
116
Practically a Master Poster
Featured Poster
jon.kiparsky
326
Posting Virtuoso
bleedi
3
Junior Poster in Training
jon.kiparsky
326
Posting Virtuoso
apines
116
Practically a Master Poster
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.