C
C
Chvalov2015-10-07 16:45:37
Java
Chvalov, 2015-10-07 16:45:37

How to access a variable within the same package?

I want to create a separate class purely for variables, what should be the class, methods and variables?
public, etc.
I swim shallowly in this, but I want to move it for convenience)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Saboteur, 2015-10-08
@Chvalov

You don't need to do this. This is contrary to the OOP ideology.
An object is not something with fields, methods, interfaces and other nonsense.
The primary meaning of an Object is that it is a data structure. And then already goes "with methods of operation with these data".
Thus, globally - an object is a place where data is stored, and variables must be encapsulated, not in the way you want.

I
illuzor, 2015-10-07
@iLLuzor

I think it will be easier to create a class with static variables.

A
abs0lut, 2015-10-07
@abs0lut

I want to create a separate class purely for variables

and what will the class methods "purely for variables" do?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question