Java中的全局变量 [英] Global variables in Java
本文介绍了Java中的全局变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Java中定义全局变量?
How do you define Global variables in Java ?
推荐答案
要定义全局变量,您可以使用静态关键字
To define Global Variable you can make use of static Keyword
public class Example {
public static int a;
public static int b;
}
现在你可以通过调用<
从任何地方访问a和b / p>
now you can access a and b from anywhere by calling
Example.a;
Example.b;
这篇关于Java中的全局变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文