Java 8 need help with a program!
Go to solution
Solved by SSL,
1 hour ago, dronikal said:I'm afraid I'm too new to java 8 to know what that is;)
Then look it up in the Java docs. It sounds like exactly what you need. As the comment above describes, use the random number as the key and the position in your list the value. When the number of elements in your TreeMap exceeds 10, just kick out the element with the smallest key (the first in the tree). I also recommend that you read about Minimum Heaps and eventually Red-Black trees, which are the implementation used for Java TreeMaps.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now