Non-static method within Static method in Java

0 votes

Why I can't call a non-static method from a static class? I am getting the below error when I try.

Cannot make a static reference to the non-static method methodName() from the type playback

Can someone explain the process of invoking a non-static method?

Sep 27, 2018 in Java by misc.edu04
• 1,430 points
250 views

1 answer to this question.

0 votes

As per my knowledge, you are getting this error because the only way to call a non-static method from a static method is through an instance of the class containing that non-static method. If you go by the definition, a non-static method is one that is called ON an instance of some class, on the other hand, a static method belongs to the class itself.

answered Sep 27, 2018 by anto.trigg4
• 3,440 points

Related Questions In Java

0 votes
1 answer

Why the main() method in Java is always static?

As you might know, static here is ...READ MORE

answered May 8, 2018 in Java by geek.erkami
• 2,680 points
710 views
0 votes
1 answer

Overriding private or static method in Java

You cannot override a private or static ...READ MORE

answered Jul 30, 2018 in Java by code.reaper12
• 3,470 points
277 views
+1 vote
2 answers

How to generate random integers within specific range in Java?

You can achieve that concisely in Java: Random ...READ MORE

answered Jul 25, 2018 in Java by samarth295
• 2,200 points
197 views
0 votes
2 answers

What is the use of toString method in Java and how can I use it ?

Whenever you require to explore the constructor ...READ MORE

answered Aug 23, 2018 in Java by Daisy
• 8,110 points
1,494 views
0 votes
2 answers

Does Java allow to create static classes?

Java has "static nested classes", but they ...READ MORE

answered Sep 5, 2018 in Java by Sushmita
• 6,890 points
127 views
0 votes
2 answers
0 votes
2 answers

Why it is not possible to define a static method in a Java interface?

Interfaces are concerned with polymorphism which is ...READ MORE

answered Aug 27, 2019 in Java by Sirajul
• 57,870 points
263 views
0 votes
1 answer

Can't access static fields in inner classes in Java

Well, the major idea behind this concept ...READ MORE

answered Oct 8, 2018 in Java by anto.trigg4
• 3,440 points
378 views
+1 vote
2 answers

Retrieve all the implementations of an interface in Java

Take a look to this example: https://github.com/burningwave/co ...READ MORE

answered Dec 20, 2019 in Java by Roberto
• 370 points

edited Jul 6 by Roberto 8,940 views