• 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

What is an instance method?

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does instance stand for int in:
int whatever(){
print blah
}
Or does int stand for integer? I'm doing an assignment where I have to put instance methods in this class and the methods work with void, not int. Help?!?!
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sara Lyons wrote:Does instance stand for int in:
int whatever(){
print blah
}
Or does int stand for integer? I'm doing an assignment where I have to put instance methods in this class and the methods work with void, not int. Help?!?!




Instance methods are methods that are not static. I will leave it to you as a research exercise to figure out what is a static method.

Henry
 
Sara Lyons
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

Sara Lyons wrote:Does instance stand for int in:
int whatever(){
print blah
}
Or does int stand for integer? I'm doing an assignment where I have to put instance methods in this class and the methods work with void, not int. Help?!?!




Instance methods are methods that are not static. I will leave it to you as a research exercise to figure out what is a static method.

Henry



So is void an instance method? Or a static method? That's all I want to know because I don't want to put int methods in my program ..it won't work.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
void indicates that a method returns no value -- it has nothing at all to do with whether the method is a static method or an instance method.

int indicates that the method returns an int value.
 
Sara Lyons
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:void indicates that a method returns no value -- it has nothing at all to do with whether the method is a static method or an instance method.

int indicates that the method returns an int value.


So what is an Instance method?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Henry already answered that: one that is not static. In other words, one that applies to each instance individually.
 
Sara Lyons
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Henry already answered that: one that is not static. In other words, one that applies to each instance individually.


But that doesn't help me at all because I don't know what a static method is.
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sara Lyons wrote:

Bear Bibeault wrote:Henry already answered that: one that is not static. In other words, one that applies to each instance individually.


But that doesn't help me at all because I don't know what a static method is.



http://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there are up to three things that can go before a method's name:

1) something that describes how widely available a method is. You will see terms like "public" or "private" These are called "access modifiers".

2) A method can be static or non-static (i'll let you figure out what the word might be for that)

3) A method can return something, or return nothing. Things it can return are pretty much ANY object type or any primitive type. OR, it may return nothing. These are labeled with a key word that means "nothing is coming back". again, i'll let you do some research to figure out what that word might be.
 
reply
    Bookmark Topic Watch Topic
  • New Topic