我有两个ArrayList:
import { HttpClientModule, HttpClient } from '@angular/common/http';
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ],
imports: [
HttpClientModule
],
schemas: [NO_ERRORS_SCHEMA],
providers: [
HttpClient,
]
})
.compileComponents();
}));
和
ArrayList<Integer> keySet = new ArrayList<Integer>();
我将如何使用keySet ArrayList作为哈希图中的键集以及值ArrayList作为HashMap中的值来创建HashMap?
答案 0 :(得分:3)
假设长度相同:
HashMap<Integer, String> a = new HashMap<>();
for(int i = 0; i < keySet.size(); i++) {
a.put(keySet.get(i), values.get(i));
}