Java String 数组:有方法的大小吗? [英] Java String array: is there a size of method?
本文介绍了Java String 数组:有方法的大小吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我来自 php 背景,在 php 中有一个 array_size()
函数,它告诉你数组中有多少元素被使用.
I come from a php background and in php, there is an array_size()
function which tells you how many elements in the array are used.
String[]
数组是否有类似的方法?谢谢.
Is there a similar method for a String[]
array? Thanks.
推荐答案
是的,.length
(类似属性,不是方法):
Yes, .length
(property-like, not a method):
String[] array = new String[10];
int size = array.length;
这篇关于Java String 数组:有方法的大小吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文