Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- public class AlphabetAssociatedLists {
- //List of String lists that will hold our associated lists
- //Use example: List.get(int index).add(String name)//List.get(getIndex(char c)).add(String name)
- //index is value of equation (for our char from char list named char c) c - 'a'
- //so it's 0 for a and 25 for z
- public static List<List<String>> lists;
- //Constructor, will be called when an object of our class is made with 'new' keywoard
- public AlphabetAssociatedLists() {
- //Fill the main List with empty array lists
- for (int i = 0; i < 26; ++i)
- lists.add(new ArrayList<String>());
- }
- //Gets index by the equation in line 7
- public int getIndex(char c) {
- return (int)c - (int)'a';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement