Java we can write a method with any number of arguments using elispe as below
protected boolean areAllStringsSet(String... theStrings){
}
When we write amethod loke this it is always better to validate whether all the arguments are valid, NOT NULL
below is a method to check and validate whether those are NULL.
you can use for any check and modify as you need
/**
* If any of the supplied strings are empty then return false;
*/
protected boolean areAllStringsSet(String... theStrings){
boolean retVal = true;
if(theStrings != null){
for(int i=0;i String str = theStrings[i];
if(str != null){
if(str.trim().length() < 0){
retVal = false;
break;
}
}else{
retVal = false;
break;
}
}
}
return retVal;
}
protected boolean areAllStringsSet(String... theStrings){
}
When we write amethod loke this it is always better to validate whether all the arguments are valid, NOT NULL
below is a method to check and validate whether those are NULL.
you can use for any check and modify as you need
/**
* If any of the supplied strings are empty then return false;
*/
protected boolean areAllStringsSet(String... theStrings){
boolean retVal = true;
if(theStrings != null){
for(int i=0;i
if(str != null){
if(str.trim().length() < 0){
retVal = false;
break;
}
}else{
retVal = false;
break;
}
}
}
return retVal;
}
No comments:
Post a Comment