File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes What is an instance method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is an instance method?" Watch "What is an instance method?" New topic
Author

What is an instance method?

Sara Lyons
Greenhorn

Joined: Dec 05, 2012
Posts: 14
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
Sheriff

Joined: Sep 28, 2004
Posts: 18829
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Sara Lyons
Greenhorn

Joined: Dec 05, 2012
Posts: 14
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

Joined: Jan 10, 2002
Posts: 61201
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sara Lyons
Greenhorn

Joined: Dec 05, 2012
Posts: 14
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

Joined: Jan 10, 2002
Posts: 61201
    
  66

Henry already answered that: one that is not static. In other words, one that applies to each instance individually.
Sara Lyons
Greenhorn

Joined: Dec 05, 2012
Posts: 14
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
Sheriff

Joined: Sep 28, 2004
Posts: 18829
    
  40

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

Joined: Oct 02, 2003
Posts: 11311
    
  16

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is an instance method?