+ 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"); } } } } }

13th Mar 2017, 8:03 AM
Ricardo Chitagu
Ricardo Chitagu - avatar
10 Respostas
+ 5
But where is you condition man ??? Without if condition how can you just give a else statement... your code is wrong buddy....
13th Mar 2017, 8:47 AM
Junaid Ashraf
Junaid Ashraf - avatar
+ 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..
13th Mar 2017, 8:50 AM
Junaid Ashraf
Junaid Ashraf - avatar
+ 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
13th Mar 2017, 8:24 AM
ODUKOYA JESUSEYITAN
ODUKOYA JESUSEYITAN - avatar
+ 1
Java
13th Mar 2017, 8:15 AM
Ricardo Chitagu
Ricardo Chitagu - avatar
+ 1
and then? I
13th Mar 2017, 8:16 AM
Ricardo Chitagu
Ricardo Chitagu - avatar
+ 1
it's the same with c.... I just need the logic. OK lemme try
13th Mar 2017, 8:18 AM
Ricardo Chitagu
Ricardo Chitagu - avatar