About this question
I want to call the variables from anywhere, for which I need to declare them as global. But don’t know how to declare global variables in java ?
I want to call the variables from anywhere, for which I need to declare them as global. But don’t know how to declare global variables in java ?
Log in to share your answer and help other learners.
Log in to answerBest Answer · By JanBask Java Expert
Answered on Jul 26, 2021
To make global variables in java , you can use the keyword static:
public class Global
{
public static int x;
public static int y;
}
Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.
Common Java interview questions, answered