【发布时间】:2011-08-02 00:59:57
【问题描述】:
假设我有这个代码
Map<String, String> list = new HashMap<String, String>();
list.put("number1", "one");
list.put("number2", "two");
我怎样才能为类型添加一些“别名”
Map<String, String>
改成更容易改写的东西,比如
// may be something like this
theNewType = HashMap<String, String>;
theNewType list = new theNewType();
list.put("number1", "one");
list.put("number2", "two");
基本上我的问题是,如何为某些“类型”创建“别名”,以便在需要更改整个程序代码时更容易编写和更容易。
谢谢,如果这是个愚蠢的问题,我很抱歉。我是 Java 新手。
【问题讨论】: