Java的:int数组,测数组元素的长度 [英] Java: Int Array, measure the length of the array element

查看:361
本文介绍了Java的:int数组,测数组元素的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java的。比方说,你给下面的数组。或者类似的东西。

In Java. Let's say you're given the following Array. Or something similar

int[] anArray = {10, 20, 30, 40, 1000};

有没有办法拿在anArray [4]数组长度元素; ?

我需要知道,如果数组[X]是== 4.在2004年或1000,1968年或

I need to know if the array[x] is == 4. As in 2004, or 1000, or 1968.

我怎样才能做到这一点?

How can i do this?

推荐答案

您可以将元素转换为字符串,并获得字符串的长度,或者其整数你可以测试,如果是1000到9999之间。

You can convert the element to a string and get the length of the string, or if its integers you can test if it's between 1000 and 9999.

这篇关于Java的:int数组,测数组元素的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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