Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. static int getLength(String... s) {
  2.  
  3. int totllength=0;
  4. if (s == null || s.length ==0){ // Array Length is 0 or Array is null
  5. return -1;
  6. }
  7. if (s.length == 1) { // one String-element
  8. return s[0].toString().length();
  9. }else { //More then one String-element
  10.  
  11. for (int i = 0; i < s.length;i++) {
  12. totllength =totllength + s[i].toString().length();
  13. }
  14. }
  15. return totllength;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement