You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在UML-Designer类图中为Java类添加List等集合类型字段?

How to Add Collection-Type Fields (like List) in UML Designer Class Diagrams

Hey there! I’ve dealt with this exact problem when designing Java projects with UML Designer, so let me break down the step-by-step process to get those List/Collection fields added correctly:

  • Open the class attribute editor: Either right-click your target class and select Properties, or double-click the class to open its details panel. Navigate to the Attributes/Fields section.
  • Manually input the collection type: In the Type field of the new attribute, directly type the full generic syntax, like List<String> or List<YourCustomClass>. UML Designer accepts this Java-style type notation even if it doesn’t auto-complete at first.
  • Use the Type Selection dialog (for auto-completion): If you prefer to pick the type from a list, click the browse icon (usually a magnifying glass or three dots) next to the Type field. In the dialog, switch to the Java Types tab, search for java.util.List, select it, and then add your desired element type in the generic parameter field (e.g., String).
  • Import the Collection type (for better support): To enable auto-completion and proper UML visualization, you can import the Java collection class into your UML model. Go to Model → Import → Java Type, search for java.util.List or java.util.Collection, and add it to your model. This will make the type appear in auto-complete menus going forward.
  • Enable generic type support (if needed): If you’re using an older version of UML Designer, check your preferences: go to Window → Preferences → UML Designer → Java, and ensure the Enable Generic Types option is checked. This ensures the tool properly renders and handles generic collection types.

A quick tip: Once you’ve added the collection field, if you’re syncing your UML diagram with a Java project, right-click the class and select Synchronize with Java Code to keep your diagram and code in sync.

内容的提问来源于stack exchange,提问作者Mark Lauer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 09:17:29