Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is an instance method?

 
Sara Lyons
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • 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?!?!
 
Henry Wong
author
Marshal
Pie
Posts: 21385
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Marshal
Pie
Posts: 21385
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
 
fred rosenberger
lowercase baba
Bartender
Posts: 12183
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic