no23

From ggc

Jump to: navigation, search

http://www.javabat.com/prob?id=Array1.no23

public boolean no23(int[] nums) {

 if(int[] != 2 || int[] != 3]

{ return true; }

else { return false; } }


This problem is unlike anything we covered in class, can you not do if statements for arrays?

Answer: you can do if statements with arrays

Solution

public boolean no23(int[] nums) {

 if (nums[0] == 2 || nums[0] == 3 || nums[1] == 2 || nums[1] ==3)
 {return false;}
 else
 {return true;}

}





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter