Questions tagged [non-static]

non-static is a term to define a function or field that is bound to some object instance. Without an instance, non static fields cannot be accessed and non static methods cannot be invoked. Unlike static, non-static methods can be overridden (virtual).

525 questions
-2
votes
3 answers

Reference of non static variable

If I refer non static variable with class name, when one object is there, why it is compile-time error? I have created one object so one set of non-static variable is there in Heap Area. So if I refer that non-static variable with class name, there…
iabhilashm
  • 11
  • 7
-2
votes
1 answer

'static' method modifier not working with Android widgets

In my Android Application, I want to change this method to static, however when I add 'static' to the method signature, my IDE tells me that a non-static context cannot be referenced from a static context (on the findViewByID(R.id.listView). public…
user4814802
-2
votes
1 answer

Static reference to a non Static field

OK, so I'm pretty sure I'm just missing something really dumb here, but for a coding assignment, I need to create a public class called 'Android' and give it instance variables and methods that meet the specifications. I keep getting the error:…
Austen Clay
  • 39
  • 1
  • 8
-2
votes
1 answer

Non-static method referenced from a static context

I have two errors both the same and they follow below: class FBox {//...} class FBPlayer { //Initialized instances FBox game = new FBox(); **FBPillar pillar = new FBPillar();** **FBObjects objects = new FBObjects();** //Lots o…
Caleb
  • 56
  • 7
-2
votes
3 answers

Recursion in non static method

I couldn't find an answer to this on the forums, sorry if this has been answered and I missed it. I am drawing a blank here on using recursion on a non static method. Example: public static void farLeft(BTNode root){ if(root !=null) …
snobbysteven
  • 29
  • 1
  • 5
-2
votes
2 answers

How can I call a non-static method (arrays)

I am trying to call my add method to add a score to my array I've got this so far, but I keep getting an error saying myQuiz was never initialized. ...................................................................................... import…
Lola Step
  • 1
  • 1
-2
votes
2 answers

New to Java programming. Trying to reference non-static variables from static content

I'm new to java programming and Stackoverflow and I had a question. I'm trying to display text assigned to variables and when I try to run the program is says that non-static variables can't be referenced from static content. Here's my code: public…
-2
votes
5 answers

How to enter a non static method from a static one

CollegeTester.java:10: error: non-static method getCommand() cannot be referenced from a static context getCommand();//goes to command ^ How would I enter this method. Making it public static void only causes more problems import…
Shimy
  • 53
  • 10
-2
votes
5 answers

Cannot make static reference to non-static object

This is my first Java project. So I'm working on my own simulation project, and some of my core stuff has gone awry. I have two classes I'm focusing on right now - settlement and townRey, which extends settlement. The error is thrown when I try…
Trent
  • 81
  • 1
  • 1
  • 7
-2
votes
4 answers

Java Thread using static or non-static nested class

I've encountered a very strange problem. My program looks like this: class Outter{ class Inner extends Thread { public void run(){ // do something } } public void func() { new…
gleery
  • 231
  • 1
  • 4
  • 10
-3
votes
1 answer

How do I use nginx on a subdomain?

I know nothing about Nginx. Could you please provide me with some guidance that I can copy and modify slightly to ensure everything works correctly? Additionally, if someone could explain how to host non-static (PHP) websites on Nginx, I would…
-3
votes
4 answers

Could someone clarify why the firstname is being printed as null in the below code?

Since it is a non-static variable, I'm trying to understand how we should call this class variable in both static & non-static method. Code: public class Person { String firstName; public static void main(String[] args) { Person pps =…
-3
votes
1 answer

Accessing inherited members from static methods - Singleton Inheritance?

Summary of the problem Actually I just want to use normal inheritance functionality. The catch is, that some of my methods are static, so they cannot access the inherited properties like normal. Furthermore, I cannot pass anything to the static…
-3
votes
4 answers

non-static variable cannot be referenced from static context [JAVA]

We have a school project where we are creating a text-based Black Jack game. I have created different classes like BlackJackDeck, Card, Hand, Player, and Dealer. My Teacher wants us to have a class called BlackJack were the game logic will be. I…
robeng
  • 85
  • 2
  • 10
-3
votes
2 answers

how to call non-static methods in main method

im trying to make a program where the user enters a number and the console is that fibonacci number. im having trouble figuring out why the like fibbonaci fib = new fibonacci is stopping my program. when the computor reads that line, the code juts…
1 2 3
34
35