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,380 points
103 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,420 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,320 points
335 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,450 points
80 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,190 points
48 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,050 points
458 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,880 points
52 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 in Java by Sirajul
• 25,180 points
64 views
0 votes
1 answer

Are arrays equivalent to objects in Java ?

Yes; the Java Language Specification writes: In the Java ...READ MORE

answered May 10, 2018 in Java by Rishabh
• 3,540 points
57 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,420 points
68 views
0 votes
1 answer

Retrieve all the implementations of an interface in Java

Hi...I think you can achieve this by ...READ MORE

answered Jul 23, 2018 in Java by anto.trigg4
• 3,420 points
521 views