forked from ChrisMayfield/ThinkJavaCode2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArgValid.java
More file actions
20 lines (17 loc) · 512 Bytes
/
ArgValid.java
File metadata and controls
20 lines (17 loc) · 512 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
* Example of argument validation.
*/
public class ArgValid {
public static boolean isCapitalized(String str) {
if (str == null || str.isEmpty()) {
return false;
}
return Character.isUpperCase(str.charAt(0));
}
public static void main(String[] args) {
System.out.println(isCapitalized("Hi!"));
System.out.println(isCapitalized("bye"));
System.out.println(isCapitalized(""));
System.out.println(isCapitalized(null));
}
}