- Are they same?
- Out of variables and methods, What we can use in context of static/non-static/instance/abstract?
Asked
Active
Viewed 64 times
-10

gprathour
- 14,813
- 5
- 66
- 90

Rajesh Negi
- 103
- 1
- 8
-
5Please read basic tutorials of Java, SO is for asking specific programming problems and cannot be used as a replacement of tutorial – Pradeep Simha Jun 09 '17 at 09:30
-
In some tutorials they are using non-static and at other places they are using instance! so i asked here – Rajesh Negi Jun 09 '17 at 09:33
-
https://stackoverflow.com/help/how-to-ask – MaVRoSCy Jun 09 '17 at 09:33
-
1https://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html – assylias Jun 09 '17 at 09:33
-
1First, @HumorousThread, you should read how to ask or at least SEARCH into stack overflow, this was already asked with at least half words the same. https://stackoverflow.com/questions/11993077/difference-between-static-methods-and-instance-methods DUPLICATED. – Foo Bar Jun 09 '17 at 09:35
-
1Possible duplicate of [Difference between Static methods and Instance methods](https://stackoverflow.com/questions/11993077/difference-between-static-methods-and-instance-methods) – ItamarG3 Jun 09 '17 at 09:36
-
I suspect that this question is a parody. – khelwood Jun 09 '17 at 09:46
1 Answers
1
Instance method and non-static methods are same thing.
Different types of methods are :
- Instance methods: Which are associated with objects.
Class methods: These are the static methods.
class Demo{ void hello(){ System.out.println("Hello"); } static void hi(){ System.out.println("hi"); } }
To call instance method you need to do,
new Demo().hello();
To call class method you can do,
Demo.hello();
In this class hello()
is instance method. Every object of Demo class will have its own copy of hello()
method.
Where as hi()
method is class method and there will be only one copy of this method in the memory. All objects will call the same method.

gprathour
- 14,813
- 5
- 66
- 90
-
downvoted because duplicated. this entire post should be removed. https://stackoverflow.com/questions/11993077/difference-between-static-methods-and-instance-methods – Foo Bar Jun 09 '17 at 09:34
-
2@FooBar That isn't really a good reason to downvote. just mark as dup and move on. – ItamarG3 Jun 09 '17 at 09:36
-
-
1@HumorousThread Yes. Instance methods and non-static methods are same. – gprathour Jun 09 '17 at 09:38
-
He´s an expert here, he should do a little research before answering questions like this. Anyway, removed the downvote. – Foo Bar Jun 09 '17 at 09:38
-
-
1@gprathour And I respect that, its a good explanation. I don´t respect the question, thats not even a question, its lazyness. Read all documentation and ASK what you are not being able to achieve, I don´t believe user make an effort before posting this question. – Foo Bar Jun 09 '17 at 09:43
-
@FooBar That's right. OP could have easily searched about the question. – gprathour Jun 09 '17 at 09:45
-
btw @Foo Bar do you have different names for maths and physics class. if yes! then sorry for asking that question if no than you should be sorry for words that you told to me and for gprathour – Rajesh Negi Jun 09 '17 at 09:55
-
@HumorousThread. First of all, Im no god in java. But I do my work. I follow simple rules, first try, second try, then (n)try. etc....If there´s something I cant achieve through my hard work. I ask. And mate, your question was originated in NOT reading and studying the documentation && tutorials, was not rocket science. – Foo Bar Jun 09 '17 at 09:56
-
ok then please show me a single post on SO where the same question is asked or where its written that **Instance Methods and non-static methods are same** – Rajesh Negi Jun 09 '17 at 09:58
-
@HumorousThread [here.](https://stackoverflow.com/questions/11993077/difference-between-static-methods-and-instance-methods) Just read it full this time: For record: "4. Static methods can be invoked by using class reference. **Instance or non static methods** are invoked by using object reference." in rashedcs answer. **Told you, your question was already answered, what is more, it was also better asked.** – Foo Bar Jun 09 '17 at 09:59
-
1@HumorousThread I dont want to be rude ok? But enough. Just delete this post, save the other one, and try to get results doing your part of the job mate, thats all. Welcome here, I hope you get to be a kickass java programmer. --And in apart, at our levels, you almost never need to ask in stackoverflow, its already answered. – Foo Bar Jun 09 '17 at 10:02
-
unable to delete question its showing that others have invested time in answering.[here](https://stackoverflow.com/help/deleted-questions) – Rajesh Negi Jun 09 '17 at 10:07
-
-