aspose file tools*
The moose likes Beginning Java and the fly likes Instance and Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Instance and Class" Watch "Instance and Class" New topic
Author

Instance and Class

ppavya india
Greenhorn

Joined: Sep 27, 2004
Posts: 19
Hi all,
I am new to Java Technology.Could anybody explain me what is the difference between instance and class.

Thanx in advance.
agSachin Agrawal
Greenhorn

Joined: Oct 07, 2004
Posts: 1
Class is a type like men is a class as me, you and millions on earth. They are of instance of class men. An instance have a physical existence like me sachin and u. But the class describes the behaviour of the instance. like all men have some common things like heavy voice, a beard etc.
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Sun has a convenient online tutorial on basic object oriented concepts and java programming. HTH.
ppavya india
Greenhorn

Joined: Sep 27, 2004
Posts: 19
Originally posted by agSachin Agrawal:
Class is a type like men is a class as me, you and millions on earth. They are of instance of class men. An instance have a physical existence like me sachin and u. But the class describes the behaviour of the instance. like all men have some common things like heavy voice, a beard etc.
ppavya india
Greenhorn

Joined: Sep 27, 2004
Posts: 19
Originally posted by agSachin Agrawal:
Class is a type like men is a class as me, you and millions on earth. They are of instance of class men. An instance have a physical existence like me sachin and u. But the class describes the behaviour of the instance. like all men have some common things like heavy voice, a beard etc.


Thanx man, and looking your help in future also.
Mahesh Bhatt
Ranch Hand

Joined: Sep 15, 2004
Posts: 88
Hi there,
Consider this, A class is an architectural design for a project. The instances are the actual concrete pieces that are then build based on this design. Apart from this please read the link to the tutorial given in the earlier post.

Hope it helps.


Impossible is I M Possible
Suhaasi Karnik
Greenhorn

Joined: Mar 15, 2004
Posts: 23
A class is a structural and functional description of an object.
An object is an actual existence (instance) of that class. Different instances can have different structural features, but they all carry out the same functions basically.

Hence when you want to create a Book, you first create a class Book which has a variable called author, nameOfBook, category.

class Book
{
String author, nameOfBook, category;
Book(String a, String n, String c)
{
author = a; nameOfBook=n; category=c;
}
}

And then you create different objects of this class, such as

Book b1 = new Book("Peter van der Linden", "Just Java 2", "Software");
Book b2 = new Book("Carl Segan", "Contact", "Science Fiction");

Thus each object will be structurally similar but can have a different state, but will exhibit similar behaviour, since they all belong to the same class.
ppavya india
Greenhorn

Joined: Sep 27, 2004
Posts: 19
Thanx all,
...got the diff. between instance and class. Ok. Now one more quetion whta is the diff. between instance methods and class methods, if possible explain me with the help of one example.
Thanx in advance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Instance and Class