+ 1
Can someone help me complete this code... If the array contains the numbers 2,3 and 5 it shud return 1 .
public class Program { public static void main(String[] args) { int [] arr={2,3,5,7,11}; for(int i=0;i<arr.length;i++){ System.out.println ("1") ; }else System .out.println ("not 235 array"); } } } } }
10 Respuestas
+ 5
But where is you condition man ??? Without if condition how can you just give a else statement... your code is wrong buddy....
+ 5
First of it will not compile only by giving a error msg like Else statement.. widout tha if sratement... I guess you havent compiled and run the code yet..
+ 2
you should use a conditional statement that checks for the digits in the array then return 1 if true
it should be more like
if( arr.contains(2) && arr.contains(3) && arr.contains(5) )
{
return 1;
}
and you shouldn't be using an else statement without an if statement
+ 1
Java
+ 1
and then? I
+ 1
it's the same with c.... I just need the logic. OK lemme try