Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.ArrayList;
  4.         import java.util.List;
  5.  
  6. public class AlphabetAssociatedLists {
  7.     //List of String lists that will hold our associated lists
  8.     //Use example: List.get(int index).add(String name)//List.get(getIndex(char c)).add(String name)
  9.     //index is value of equation (for our char from char list named char c) c - 'a'
  10.     //so it's 0 for a and 25 for z
  11.     public List<List<String>> lists;
  12.  
  13.     //Constructor, will be called when an object of our class is made with 'new' keywoard
  14.     public AlphabetAssociatedLists() {
  15.  
  16.         //Fill the main List with empty array lists
  17.         for (int i = 0; i < 26; ++i)
  18.             lists.add(new ArrayList<String>());
  19.     }
  20.  
  21.     //Gets index by the equation in line 7
  22.     public static int getIndex(char c) {
  23.         return c - 'a';
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement