So i was using Eclipse to create a simple program, in this program I have a object that has no other methods other than the constructor. Something like this
class Example{
public Example(...)
{
//Do something with the variable
}
}
The whole logic of Example class is in the constructor, there will be no more methods for this class.
When i instantiate an object of this class, I get these "unused" warnings. I don't want to suppress all the unused warnings, I just want warnings to be suppressed when I instantiate this object.
Again, I don't want to supresswarnings where I use Example class as there will be multiple places where I use it and I don't want to riddle my code with these useless supresswarnings.
The whole logic of Example class is in the constructor
That sounds like a poor design to start with. If you don't really need an instance, why create it? It sounds like you should probably just put the code from the constructor into a static method.
If you do want to keep the class (e.g. because you use instance variables), I would suggest moving most of the logic out of the constructor, into appropriate instance methods, but then possibly have a static method which calls the constructor and then the relevant methods.
It's hard to tell without knowing what your code is actually doing, but I wouldn't be looking to suppress warnings here - I'd strongly suggest refactoring the code instead.
See more on this question at Stackoverflow