请教一个简单的String算法,来看看 if (s.equals("aaa") || s.equals("bbb") || s.equals("ccc")){ return true;}else{ return false;} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不对啊,我的String不是常量,是变量啊 mymoto(向下一步艰难迈进) 是正确的!为什么不试试先! public boolean method(String s) { boolean ret = false; String strTest = "aaa,bbb,ccc,ddd,"; int nBeginIndex = 0; int nEndIndex = 0; nEndIndex = strTest.indexOf(",",nBeginIndex); while(nEndIndex>0) { if((strTest.substring(nBeginIndex,nEndIndex)).equals(s)) { ret = true; break; } else { nBeginIndex = nEndIndex + 1; nEndIndex = strTest.indexOf(",",nBeginIndex); } } return ret; } 我想用JAVA 簡單做一個接收LLDP封包的程式 有关多线程的问题 帮我分析一下以下的语句大概的意思 关于TreeSet实现数据存储问题 关于linux环境下界面程序中文无法显示的问题.急!!! 前辈请留一下步 请问:我在输出字符串的时候怎么才可以连续的输出同样的? 大家过来具体讨论一下:c/s与b/s的区别? 高位高手,有没有关于java类的使用方法和说明的资料(中文的) replaceAll做替换是不是有什么限制呀! java 如何使成员方法不改变数据成员 关于两个double数相加,结果小数点后面有个好长的尾数,什么原因? 疑问!为何getDate返回的Date只是精确到天的?
为什么不试试先!
{
boolean ret = false;
String strTest = "aaa,bbb,ccc,ddd,";
int nBeginIndex = 0;
int nEndIndex = 0;
nEndIndex = strTest.indexOf(",",nBeginIndex);
while(nEndIndex>0)
{
if((strTest.substring(nBeginIndex,nEndIndex)).equals(s))
{
ret = true;
break;
}
else
{
nBeginIndex = nEndIndex + 1;
nEndIndex = strTest.indexOf(",",nBeginIndex);
}
}
return ret;
}