作者:无可奈何花落去 | 来源:互联网 | 2023-02-13 15:38
let say I have this code
让我说我有这个代码
Map list = new HashMap();
list.put("number1", "one");
list.put("number2", "two");
how can I make some "alias" the type
我该如何制作一些“别名”类型
Map
to something that easier to be rewritten like
更容易被重写的东西
// may be something like this
theNewType = HashMap;
theNewType list = new theNewType();
list.put("number1", "one");
list.put("number2", "two");
basically my question is, how to create "alias" to some "type", so i can make it easier to write and easier when need to change the whole program code.
基本上我的问题是,如何为某些“类型”创建“别名”,因此当需要更改整个程序代码时,我可以更容易编写和更容易。
Thanks, and sorry if this is silly question. I'm kinda new in Java.
谢谢,对不起,如果这是一个愚蠢的问题。我是Java的新手。
5 个解决方案