Java Reference
In-Depth Information
factors. Remember that a prime number's factors are only 1 and the prime number itself. Every
number that's not prime has a unique prime factorization. For example, consider the number 54.
The prime factors of 54 are 2, 3, 3 and 3. When the values are multiplied together, the result is 54.
For the number 54, the prime factors output should be 2 and 3. Use Set s as part of your solution.
16.20 (Sorting Words with a TreeSet ) Write a program that uses a String method split to to-
kenize a line of text input by the user and places each token in a TreeSet . Print the elements of the
TreeSet . [ Note: This should cause the elements to be printed in ascending sorted order.]
16.21 (Changing a PriorityQueue 's Sort Order) The output of Fig. 16.15 shows that Priority-
Queue orders Double elements in ascending order. Rewrite Fig. 16.15 so that it orders Double ele-
ments in descending order (i.e., 9.8 should be the highest-priority element rather than 3.2 ).
Search WWH ::




Custom Search