• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

instance & class methods

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks,
I am new to java, can someone explain me the the diff. between instance methods and class methods, if possible explain me with the help of one example.

Thanx in advance.
 
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I assume that you, by class method, mean static method.

The definitions:

Instance members are instance variables and instance methods of
an object. They can only be accessed or invoked through an
obj. reference.

Static members are static variables and static methods of a class.
They can be accessed or invoked eighter using the class name
or though an obj. reference.

Let's return to your question. An instance method belongs to an instance of
the class and a static (class) method belongs to the class and not
to any object of the class.

Example: We have a Person class that has a static variable id and an
instance variable name. I hope the example will show you the difference
between static and instance members.

Notice that I can call the static method without having to instantiate
an object.



/Svend Rost

Edit: Removed a misplaced UBB Code

[ October 11, 2004: Message edited by: Svend Rost ]
[ October 11, 2004: Message edited by: Svend Rost ]
 
ppavya india
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Svend Rost,
You have given really good explaination about all my queries (basic concepts). Thanx man, thanx a lot. Svend I have one request, could you please give me your personal e-mail id as you have provided really good explaination, and I need your help for next 6(minimum) months as I have just started Java one month before.
Waiting for your reply.
Thanx in advance.
 
Svend Rost
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im glad my answer was helpfull...

I'd like to help, but it's easier if you post the questions here.

By doing that, other people also get a chance to learn from the
questions/answer..

/Svend Rost
 
ppavya india
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Svend,
You are right, other people would also get a chance to learn from the
questions/answer..
Well, my next query is that, I am new to java, I want to be a professional in java programming, tell me what should be my first step. I have searched on google for java tutorials, I got too many. But I am confused which tutorial I should start. Svend could you please tell me the, from your point of view which is the best site for java tutorial that provides very good materials right from basics to advanced java programming.

Thanx in advance, Svend I am waiting for your reply.
 
Svend Rost
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am new to java, I want to be a professional in java programming, tell me what should be my first step



A better place to ask this question would be the "job discussion" forum. What
way to go depends on your age, background, where you live and what your
goals are.

from your point of view which is the best site for java tutorial that provides very good materials right from basics to advanced java programming.



Personaly I prefeer a textbook, but there's also a lot of good information
on the net. Im proberly not best person to guide you to the best
java tutorials, but I after a quick search on the net I found the following
sites promissing:


<a href="http://java.sun.com/developer/onlineTraining/</a >" target="_blank">
http://java.sun.com/developer/onlineTraining/[/URL]
- Take, for instance, a look at the short course by jGuro called Language Essentials Short Course. There is also the Essentials of the Java Programming Language: A Hands-On Guide, Part 1* and Part 2 under the
headline "Java Technical Content".

http://www.javaworld.com/
- Javaworld has a lot of good articles about almost anything. This might
be a place to look once you understand the basics of Java and OOP.

I might add more, when I get some more time on my hands..

/Svend Rost
 
ppavya india
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx Svend, thanx a lot. And looking for your help in future also.

Thanx again.
 
reply
    Bookmark Topic Watch Topic
  • New Topic