I really need to re-arrange all my functions. I created a class. All my var, booleans, int, doubles and other things. I created every new variable so they can reference it and so they don't have an error. If your asking why I never just reference my main class vars to my sub-class becuase it will give me stack overflow! When in my main class i link my sub-class.

subClass s = new subClass(); 

Then I reference my fake variable to my real variable for example: This is my sub-class variable(I call it fake)

public int x = 0;

In my main class, I put it like this:

s.x = x;

The problem is, it does not work! Maybe this is not the right place but I cant ask any questions on stack overflow because they banned me. If I connect my main class and connect my sub-class it will give me stack overflow. How do I stop it?

share|improve this question

30% accept rate
4  
I think it would be best for you to get a book about getting started in Java programming and learn the basics. Your questions indicate a lack of understanding of the OOP basics (or you're trolling). Either way, this question will get closed as well as it's off-topic and not really answerable. – bummzack Oct 6 at 8:25
You are not referencing. You are copying. – Arthur Wulf White Oct 6 at 8:28
1  
You got banned, it must be a useful indication that you should rethink the way you are using stackexchange. – Arthur Wulf White Oct 6 at 10:27
feedback

closed as off topic by bummzack, Jari Komppa, Jonathan Hobbs, Byte56, Tetrad Oct 6 at 17:01

Questions on Game Development - Stack Exchange are expected to relate to game development within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

What you need to do is:

public Integer x = 0;

s.x = x;

You would need to use:

Integer 

and not

int

Anywhere you are treating this variable and its references.

Also, if you call a function with 'x' and expect it to change its contents, that will not work because Java uses call by value on ints.

share|improve this answer
feedback

Not the answer you're looking for? Browse other questions tagged or ask your own question.