作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在用 java 编写一个程序,它将使用字符串数组:
String[] category = new String[46];
然后我将检查 for 循环中的数组是否已经有值,
for(int checking = 21; checking <= 45 ;checking++) {
if(category[checking]=INSERT_HERE) {
textArea += category[checking] + "\n";
}
}
我应该在 INSERT_HERE 中放入什么?注意:textArea 是一个命名的 JTextArea
。
最佳答案
如果您要检查值是否不为空,请使用
if(category[checking]!=null)
如果您要检查某个特定值,那么
if(category[checking].equals(PARTICULAR_VALUE))
PS:“=”用于赋值,应该使用“==”进行比较。
关于Java字符串数组: how do I check if the array has a value?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22039576/
我是一名优秀的程序员,十分优秀!