JAVA problem answer?

In the following code fragment, a is a five-element array of Strings and b is a boolean. Write code that assigns true to b if the elements of a are in lexicographical order (without repeats), and assigns false to b if not. For example, if a is the array with elements "my", "kingdom",... show more In the following code fragment, a is a five-element array of Strings and b is a boolean. Write code that assigns true to b if the elements of a are in lexicographical order (without repeats), and assigns false to b if not. For example, if a is the array with elements "my", "kingdom", "for", "a", "horse" (in that order), then after executing your code b should have the value false. On the other hand, if a is the array with elements "chocolate", "kisses", "make", "people", "smile" (in that order), then after executing your code b should have the value true.








In the following code fragment, b is a four-element array of booleans and onlyone is a boolean. Write code that assigns true to onlyone if and only if exactly one element of b is true.
1 answer 1