| Author |
Static
|
Prasad Chelur
Greenhorn
Joined: Feb 12, 2002
Posts: 10
|
|
|
Sir please give me some real time example where we can use static method(we have to use only static method)
|
prasadcts
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
Prasad, Welcome to JavaRanch! We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy. Thanks Pardner! Hope to see you 'round the Ranch!
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
|
|
Do you mean an example of the use of static methods in solving a real-time programming problem? You would not normally choose Java to implement a real-time (even soft real-time) process because of the possible impact of garbage collection (even if it runs as a low-priority thread). Do you have an example of an example in mind? Maybe you mean a program using just primitive data types and static methods, or possibly objects that once referenced are never released by setting the reference to null. Could you mean something like LeJos a JVM (which has no garbage collection) developed for Lego (TM) Mindstorms RCX bricks? -Barry [ January 04, 2003: Message edited by: Barry Gaunt ]
|
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
|
 |
Marilyn de Queiroz
Sheriff
Joined: Jul 22, 2000
Posts: 9033
|
|
Or do you just want an example of a static method?
|
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
|
 |
k Oyedeji
Ranch Hand
Joined: Jul 07, 2002
Posts: 96
|
|
I think he's asking for an example of when it would be appropriate to use a static method. Kola
|
 |
Robbie shi
Greenhorn
Joined: Jan 05, 2003
Posts: 28
|
|
specify that a member variable is a class variable, use the static keyword. For example, let's change the AnIntegerNamedX class such that its x variable is now a class variable: ----- Robbies ----------------------------- 1.java IDE tool : JawaBeginer 2.Java Jar tool : JavaJar web page -----------------------------
|
 |
kishor rao
Ranch Hand
Joined: Dec 10, 2002
Posts: 35
|
|
|
say u want to keep count of how many objects of a class u have. then have a static counter and a static method to increment the static counter(cos only static methods can change static variables). have the constructor call the static method, so the static variable is changed everytime the class is instantiated.
|
 |
 |
|
|
subject: Static
|
|
|