Map<String,String> test =
new HashMap<String, String>{"test":"test","test":"test"};
Is there a way to initialize HashMap like the code above? Is the code above grammatically correct?
You can't use the code above. You have to add them to the elements one by one.
public class Demo
{
private static final Map<String, String> myMap;
static
{
myMap = new HashMap<String, String>();
myMap.put("a", "b");
myMap.put("c", "d");
}
}
911 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
578 Understanding How to Configure Google API Key
610 GDB gets version error when attempting to debug with the Presense SDK (IDE)
617 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.