Linked Questions
67 questions linked to/from Calling Non-Static Method In Static Method In Java
116 votes
8 answers
496k views
Cannot make a static reference to the non-static method
Building a multi-language application in Java. Getting an error when inserting String value from R.string resource XML file: public static final String TTT = (String) getText(R.string.TTT); This is ...
27 votes
6 answers
314k views
calling another method from the main method in java [duplicate]
I have class foo{ public static void main(String[] args){ do(); } public void do(){} } but then when I call do() from main by running the command java foo on the command line, java ...
0 votes
3 answers
12k views
Non-static method cannot be referenced from a static context (Java) [duplicate]
I'm newer to programming and keep getting the non-static method cannot be referenced from a static context when calling my floor class from my ant class. I've removed all statics and am still getting ...
1 vote
4 answers
10k views
Can an Static Method call an Instance Method in Java [duplicate]
So I just started programming and what not and this question has me tearing my hair off. It's asking "Under what circumstances, if any, can a static method call an instance method?" I've tried going ...
0 votes
2 answers
2k views
Calling non-static methods in java [duplicate]
I have question about static methods in Java. Why is that I can call a non-static method in another non-static method without specifying an instance of the class. For example if I have two non-static ...
0 votes
1 answer
2k views
How do I call a method into the public static class to be used? [duplicate]
I am new coder taking a class over computer science. We are working with Java. The assignment was given through a pdf that I reuploaded as a photo here https://i.sstatic.net/xNEdm.png. Here is my code ...
-1 votes
1 answer
2k views
How to call non-static method from static method? [duplicate]
I am using swing to make a java project with JFrames. I am trying to call the non-static method build(), which builds the JFrame with its components. However, build can't be static because I am using ...
0 votes
5 answers
316 views
static non-static reference confusion [duplicate]
UPDATE: I made some changes based on some answers I got and it worked. The correct code is- public class Tsett { static HashSet<String> names=new HashSet<String>(); static ...
0 votes
2 answers
934 views
non-static method cannot be referenced from a static context [duplicate]
Possible Duplicate: calling non-static method in static method in Java I am running into the "non-static method cannot be referenced from a static context"-error when i try to call a method that ...
-4 votes
1 answer
862 views
Non-static methods cannot be referenced from a static context from within the same class [duplicate]
I have got through most of my code for a Student Registration Interface without difficultly, however I am getting this error. non-static method cannot be referenced from a static context. Now, I ...
0 votes
1 answer
974 views
Get non-static string from static method [duplicate]
I'm getting an error when I try to get a non-static string in a static class. this is the warning message "non static field cannot be referenced from a static context" I want to get DOWNLOAD_URL ...
-2 votes
1 answer
744 views
Non-Static Call - IntelliJ Thinks It's Being Accessed From Static Method [duplicate]
I have read this question, but my issue is different because mine isn't about this error message specifically; I was just using it to realize I had made a different kind of mistake. Please read my ...
0 votes
3 answers
592 views
Getting an error for a non static method that cant be referenced from a static context [duplicate]
when i try to compile this it gives me an error for a non-static method begin(int) cannot be referenced from a static context. Any way this can be fixed? import java.util.Scanner; import objectdraw.*;...
4 votes
2 answers
169 views
why you can call a non-static method in the main method by creating an object? Java [duplicate]
I can create an object in the main method and call the other method with the object I created. public class Obj{ public static void main(String[] args) { Obj obj = new Obj(); obj....
-3 votes
3 answers
405 views
Call non-static method from static context [duplicate]
So I know there are probably 100 threads about this topic already. Yes I tried to read them but i can't for my life understand the concept of context in Android :( I want to call a non-static method ...