Map<String,String> maps = new HashMap<>(); maps.put(rongtongDept, rongtongCode); maps.put(neijiangDept, neijiangCode); maps.put(jiangyouDept, jiangyouCode); maps.put(dept, purchaseRequestCode); maps.put(dept2, purchaseRequestCode2); 把这段代码变成一个可以复用的方法
时间: 2024-03-16 19:47:39 浏览: 79
好的,我来为您编写这个可以复用的方法:
```
public Map<String,String> createMap(String rongtongDept, String rongtongCode, String neijiangDept, String neijiangCode, String jiangyouDept, String jiangyouCode, String dept, String purchaseRequestCode, String dept2, String purchaseRequestCode2) {
Map<String,String> maps = new HashMap<>();
maps.put(rongtongDept, rongtongCode);
maps.put(neijiangDept, neijiangCode);
maps.put(jiangyouDept, jiangyouCode);
maps.put(dept, purchaseRequestCode);
maps.put(dept2, purchaseRequestCode2);
return maps;
}
```
在调用该方法时,您需要传入该方法所需的参数,即:`rongtongDept`、`rongtongCode`、`neijiangDept`、`neijiangCode`、`jiangyouDept`、`jiangyouCode`、`dept`、`purchaseRequestCode`、`dept2`、`purchaseRequestCode2`。例如:
```
Map<String,String> maps = createMap("融通部门", "融通编码", "内江部门", "内江编码", "江油部门", "江油编码", "部门", "采购请求编码", "部门2", "采购请求编码2");
```
您可以根据实际情况,更改参数名称和参数类型。
阅读全文