Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- getLength("Hallo");
- System.out.println(getLength("Hallo")); // 5
- System.out.println(getLength(null)); // -1
- System.out.println(getLength("")); // 0
- System.out.println("=========================");
- System.out.println((getLength(new String[0])));
- System.out.println((getLength(new String[] { "a", "b" })));
- }
- private static int getLength(String... checkString) {
- if (checkString == null || checkString.length == 0) {
- return -1;
- } else if (checkString.length == 1) {
- return checkString[0].length();
- } else {
- return checkString.length;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement