method and class in Java
I am a learner.
I want to know what the difference is between the class and method. Because I saw a example "class FahrToCelsius". I think I can write a method FahrToCelsius in the main function instead of the class.
when should I write a class? method like this?
another think. because java is a oo, so the method should be called by the object, a instance of the class. but I read some example ,the class could call the method. why?
when does the call the method? object?
Thanks for anyone who will give me some hints.
[560 byte] By [
lance82a] at [2007-11-27 8:46:25]

> I want to know what the difference is between the class and method. Because I
> saw a example "class FahrToCelsius". I think I can write a method
> FahrToCelsius in the main function instead of the class.
There are times when a class seems to exist mainly to define one primary method,
see the Command Pattern:
http://en.wikipedia.org/wiki/Command_pattern
Hi thanks for replying.I guess if the method is static, then this method does not need to be called by class or object. just like a function in vbbut how about called by class. I am still reading. If someone could give me a instantly answer, that should be perfect
> I guess if the method is static, then this method
> does not need to be called by class or object. just
> like a function in vb
If the method is static, you do not have to call it on an object, but you DO have to call it on a class.
> but how about called by class.
What do you mean?
> If someone could give me a instantly answer, that
> should be perfect
You probably don't mean to be rude here, but asking for something "instantly" or "urgently", "ASAP", etc. tends to irritate people. We answer questions here because we enjoy it, and we do so at our own pace. Being pushed for something "now" makes it less fun.
jverda at 2007-7-12 20:48:40 >
