我们可以使用变量作为数组大小吗 [英] can we use variable as an array size

查看:289
本文介绍了我们可以使用变量作为数组大小吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我有一个要动态更改大小的字符串数组,该大小要在该类的私有成员的变量中动态使用.但是当我尝试在数组的()中进行设置时,我找不到变量名.谁能告诉我隐藏变量背后的原因?请举一个例子

hi all,


i have a string array which size i want to change dynamically use in a variable which is private member of the class.But i could not find variable name when i''m try to set inside the () of an array. can anyone tell me reason behind the hiding of the variable?. please reply with an example

推荐答案

[ ^ ]可能会给您一个想法.
this[^] might give you an idea.


我不太了解您的问题.如果您声明一个私有字段,那么您将无法在班级之外访问它.

如果您希望数组的大小可以动态更改,则应使用ArrayList.
I don''t really understand your question. If you declare a field private you can''t access it outside your class.

If you want an array with a size that can change dynamically, you should use a ArrayList.


这篇关于我们可以使用变量作为数组大小吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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