jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes obiect/class/method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "obiect/class/method" Watch "obiect/class/method" New topic
Author

obiect/class/method

Abdul Rahim1972
Greenhorn

Joined: Oct 27, 2001
Posts: 1
I want o know the difference between CLASS/OBJECT and METHOD in java.
Please explain in simple words.
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

A class is a container of variables and methods. A class should contain methods and variables which are related in some way. A method is a specific task or job which gets performed on a class.
An example might be a bank class. If you wanted to represent a bank as a class you would have variables and methods which have something to do with banking. So methods might be: depositMoney, withdrawMoney, and a variable might be currentBalance.


Please ignore post, I have no idea what I am talking about.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
A Class is a definition of a type of object and a place to store things that are valid across all objects of the Class (static variables).
An object of the Class is an instance of of something created from that definition.
Member variables (also known as instance variables) are places to store the STATE of the object at any given time.
Methods are written in the Class and define the BEHAVIOR of an object. You know - things that it can DO with instructions (code) on how to get it done.
Local variables (created inside methods or blocks) are temporary working variables that are disposed of as soon as the block or method is complete.

[This message has been edited by Cindy Glass (edited October 28, 2001).]


"JavaRanch, where the deer and the Certified play" - David O'Meara
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Abdul Rahim1972,
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at "JavaRanch Naming Policy" . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. We would like this forum to be as Professional as possible. Please choose a new name which meets the requirements.
Thanks,
Cindy
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
Think of a class as a cookie cutter. With a class (that contains fields and methods) you can create as many objects of that type class as you want to.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: obiect/class/method
 
Similar Threads
How to call a stand alone class from WAS???
java.lang.OutOfMemoryError: PermGen space
Object
Events
deprecated methods