Print Java Packages as Indented Tree

Problem Given a list of fully-qualified Java names (e.g. java.util.vector, java.util.Date, org.json.JSONObject, java.util.regex.Pattern), print them as an indented tree grouped by package segment — one segment per line, children indented under their parent.

Input / Output

  • Input: a list of dotted names.
  • Output: the printed hierarchy — each segment on its own line, indentation proportional to depth (e.g. java → util → {vector, Date, regex → Pattern}).

Constraints

  • Up to 10^4 names. Clarify sibling ordering (alphabetical vs insertion) and how duplicates should be handled.

Example

  • [java.util.vector, java.util.Date, org.json.JSONObject] → java / (indent) util / (indent×2) vector, Date; org / (indent) json / (indent×2) JSONObject.
asked …
LeaderboardSalaryAccount