Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Overview of Basic Collection Types

This chapter introduces several fundamental Collection types commonly used in the Cangjie language, including Array, ArrayList, HashSet, and HashMap.

You can choose the appropriate type for specific business scenarios:

  • Array: When you don’t need to add or remove elements but require element modification
  • ArrayList: When frequent element insertion, deletion, querying, and modification are needed
  • HashSet: When you want each element to be unique
  • HashMap: When you need to store a series of key-value mappings

The following table summarizes the basic characteristics of these types:

Type NameMutable ElementsAdd/Remove ElementsElement UniquenessOrdered Sequence
Array<T>YNNY
ArrayList<T>YYNY
HashSet<T>NYYN
HashMap<K, V>K: N, V: YYK: Y, V: NN