为什么访问说明符不能用于在Java类中的方法中声明的变量? [英] Why access specifiers can't be used for variables declared inside method in a Java Class?

查看:231
本文介绍了为什么访问说明符不能用于在Java类中的方法中声明的变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我们不能对Java类中的方法中声明的变量使用访问说明符?

Why we can't use access specifiers for variables declared inside method in a Java Class?

推荐答案

t有意义。方法中声明的变量是方法的局部变量;即它们不能在该方法之外访问。什么修改变量的声明实现?

Because it doesn't make sense. Variables declared in a method are local to the method; i.e. they can't be accessed outside the method. What would modifying the variable's declaration achieve?

这篇关于为什么访问说明符不能用于在Java类中的方法中声明的变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆