Java does not support global variables grammatically, but you can use the static keyword to use them like global variables.
public class Example{
public static int a;
public static int b;
}
If you create a static variable like this
Example.a = 10;
Example.b = 20;
You can access it this way from where you want to use it.
© 2024 OneMinuteCode. All rights reserved.