Java doesn't provide library (API) for trie. You implement a trie just like building a tree. You define a TrieNode class first. It has a data structure called children, which is used to find next nodes in branches from the current character. Then you define a Trie class. It has a root node. You insert a word by adding nodes from the first character to the last.