Explain your own example of how you can use Java Math and String capabilities to find out something about a textual String object.
You can use Math.max () and String.charAt () to find out the maximum ASCII value in a string. Sample code:
String example = "That's an example!";
int max = example.charAt(0);
for (int i = 0; i < example.length(); i++) {
max = Math.max(example.charAt(i), max);
}
Comments
Leave a comment