Basic Java Help Variable Resets when Calling Other Class
Go to solution
Solved by Arberden,
A class stores nothing.
A class is more like a building guide for objects.
If you call the Constructor you basicaly create an object.
This object can store data in the predefined variables.
You can save the referenc to an Object to an Variable.
Database myDB = new Database();Database myDB2;myDB2 = myDB;All the changes you make by calling the methods in myDB2 will also effcet myDB (and vice versa), as they both reference the same object you created with new Database()
So how do i call a method from another class without resetting its variables
Solved using static to call the methods so i do not need to declare the constructor
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now