Hello Coders J My program consist of several classes. I find it more readable,logic and useful to declare all the methods in all the classes �static� and get access by Class.member(). The problem showed up when I must use a java biuld-in method( as Component.remove ) within my static method , then I receive compile error. The first alternative is to create the class instance inside the static my static method , the second is to use interface which declare its member as static final. The two ways doesn�t fit to my needs , do anyone know another way? Thanks in advance Shay
It is really hard to say without seeing any code, but if you pass a reference to the instance of the Component as a parameter to the static method and use it as a local variable you can act on it. Many of the methods in the API are static and take in objects.
"JavaRanch, where the deer and the Certified play" - David O'Meara
Joined: Sep 03, 2001
Hello i feel like an OOP's traitor I�ve been told that I violate the OOP design�s rules in Java�s OOP design whenever I use only static members instead of creating class instances. Can anyone tell about the deficiencies and advantages of using the both form static and OOP? thanks Shay Gage
I guess I don't understand why you want to declare everything static. You say it is more "readable, logic and useful", but I don't know what you mean. You need to be careful if you are declaring everything static. static means you only have one copy and if you have different code all calling the same static method you can get confusing results.
Please ignore post, I have no idea what I am talking about.
If you are using all static code, it seems that you are only doing procedural programming and using classes as functions rather than using abstraction, polymorphism, inheritance, and encapsulation which are the cornerstones of OOP.
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt