Answer the question
In order to leave comments, you need to log in
Is it possible to create variables in java that will be available between all classes?
There are several variables (constants), and there are several classes. Variables are used in almost all classes. How to make them available to all classes without initialization?
Answer the question
In order to leave comments, you need to log in
In general, it is bad practice to use global variables in OOP, but if you cannot do without them (and if they are constants), then fields with public static final modifiers are written in one class or interface, and then in all other classes these fields are accessed .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question