菜鸟的问题!!!在线等!! 我想知道这个判断用什么语句,,并且举一个例子。一个数组里有7个元素并且给出要求我们输入一个数字,判断是不是数列里的数。谢谢大家了····· 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 String [] str1= {"1","2","3","4","5","6","7"}; String str2 = "2"; for(int i=0;i<str1.length;i++){ if(str1[i].equals(str2)){ System.out.println("有相同"); break; } if(i==str1.length-1 && !str1[i].equals(str2)){ System.out.println("没有相同"); } } public class SplitDemo { private static int NUM = 4; public static void main(String[] args) { int count = 0; int[] arrNum = {3, 12, 34, 45, 56}; for(int i : arrNum) if(i == NUM) count ++; if(count > 0) { System.out.println("有"); }else{ System.out.println("无"); } } } 只有7个元素并且是char或int类型的话用switch也可以的 public class SplitDemo { private static int NUM = 4; public static void main(String[] args) { int count = 0; int[] arrNum = {3, 12, 34, 45, 56}; for(int i : arrNum) if(i == NUM) count ++; if(count > 0) { System.out.println("有"); }else{ System.out.println("无"); } } }嗯这个行 求助:如把下面代码里的字段赋值啊 有人帮我吗?很简单的问题诚心询问 【求助】一道关于接口的题 动态创建控件问题!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!(急) java application 怎么设置面板背景图? jsp能在网页中获取超过2G的文件的信息吗? 如何得到一个String对象的地址? 初学java,不知道用什么调试好 “Exception in thread "main" java.lang.NoSuchMethodError: main”问题 ~~~请教高手~~~ 关于sin的applet。求解析 图片显示不出来
String str2 = "2";
for(int i=0;i<str1.length;i++){
if(str1[i].equals(str2)){
System.out.println("有相同");
break;
}
if(i==str1.length-1 && !str1[i].equals(str2)){
System.out.println("没有相同");
}
}
public class SplitDemo {
private static int NUM = 4;
public static void main(String[] args)
{
int count = 0;
int[] arrNum = {3, 12, 34, 45, 56};
for(int i : arrNum)
if(i == NUM) count ++;
if(count > 0)
{
System.out.println("有");
}else{
System.out.println("无");
}
}
}
private static int NUM = 4;
public static void main(String[] args)
{
int count = 0;
int[] arrNum = {3, 12, 34, 45, 56};
for(int i : arrNum)
if(i == NUM) count ++;
if(count > 0)
{
System.out.println("有");
}else{
System.out.println("无");
}
}
}
嗯这个行