Home
Classrooms
Courses
About Us
Resources
Members
More
https://codingbat.com/prob/p186672
Solve this problem, then comment your solution.
public boolean only14(int[] nums) {
for(int i = 0; i < nums.length; i++) {
if(nums[i] == 1 && nums[i] == 4){
return true;
}
else return false;
did u copy me lol
for(int i=0; i<nums.length; i++){
if (nums[i]==1);
else if (nums[i]==4);
boolean isTrue = true;
for (int i = 0; i < nums.length; i++) {
if (nums.length[i] ? = 1; nums.length[i] ! = 4;)
isTrue = false;
return isTrue;
it kinda works
stop copying me XD
public boolean only14(int[] numbers) {
int index = 0;
boolean only1or4 = true;
while(index <= numbers.length - 1){
int a = numbers[index];
switch (a){
case 1:
case 4:
break;
default:
only1or4 = false;
index = index + 1;
if( only1or4 == true)
return(true);
else
return(false);
public boolean only14(int[] nums) {
for(int i = 0; i < nums.length; i++) {
if(nums[i] == 1 && nums[i] == 4){
return true;
}
}
else return false;
}
}
did u copy me lol
public boolean only14(int[] nums) {
for(int i=0; i<nums.length; i++){
if (nums[i]==1);
else if (nums[i]==4);
else return false;
}
return true;
}
public boolean only14(int[] nums) {
boolean isTrue = true;
for (int i = 0; i < nums.length; i++) {
if (nums.length[i] ? = 1; nums.length[i] ! = 4;)
isTrue = false;
}
return isTrue;
}
public boolean only14(int[] numbers) {
int index = 0;
boolean only1or4 = true;
while(index <= numbers.length - 1){
int a = numbers[index];
switch (a){
case 1:
case 4:
break;
default:
only1or4 = false;
}
index = index + 1;
}
if( only1or4 == true)
return(true);
else
return(false);
}