本文介绍了Java静态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

重复

我读过已经。

方法中的static关键字是做什么的?

What does the "static" keyword in a method do?

我记得被告知静态!=紧贴......但这就是我对这个关键字的全部了解。

I remember being told that static != clingy...but that is pretty much all I know about this keyword.

推荐答案

静态类变量可以被认为是一个全局类。无论你有多少个类实例,每个静态变量只有一个实例。

Static class variables can be thought of as a global class. No matter how many instances of the class you have, there is just one instance of each static variable.

静态方法不使用任何非静态类变量可以直接从类外部调用,而无需实例化类本身。

Static methods don't use any non-static class variables and they can be called directly from outside of the class without having to instantiate the class itself.

这篇关于Java静态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 16:26