EduardoElias Well-Known Member Licensed User Longtime User Mar 21, 2022 #1 I am trying to use: B4X: private static Map convertToMap(HashMap<?, ?> javaMap) { Map m = new Map(); m.Initialize(); for (Entry<?, ?> e : javaMap.entrySet()) { m.Put(e.getKey(), e.getValue()); } return m; } However I am getting java:721: error: cannot find symbol Map m = new Map(); ^ What is the include that I need? Already doing this: import anywheresoftware.b4a.BA; import anywheresoftware.b4a.*;
I am trying to use: B4X: private static Map convertToMap(HashMap<?, ?> javaMap) { Map m = new Map(); m.Initialize(); for (Entry<?, ?> e : javaMap.entrySet()) { m.Put(e.getKey(), e.getValue()); } return m; } However I am getting java:721: error: cannot find symbol Map m = new Map(); ^ What is the include that I need? Already doing this: import anywheresoftware.b4a.BA; import anywheresoftware.b4a.*;
Erel B4X founder Staff member Licensed User Longtime User Mar 22, 2022 #2 import anywheresoftware.b4a.objects.collections.*; Upvote 0
EduardoElias Well-Known Member Licensed User Longtime User Mar 22, 2022 #3 Erel said: import anywheresoftware.b4a.objects.collections.*; Click to expand... I am getting this now: error: Map is abstract; cannot be instantiated Map m = new Map(); ^ Upvote 0
Erel said: import anywheresoftware.b4a.objects.collections.*; Click to expand... I am getting this now: error: Map is abstract; cannot be instantiated Map m = new Map(); ^
Erel B4X founder Staff member Licensed User Longtime User Mar 22, 2022 #4 It will be easier to help if you provide more context. Where do you put this code? Based on the error it treats the Map as java.util.Map. Upvote 0
It will be easier to help if you provide more context. Where do you put this code? Based on the error it treats the Map as java.util.Map.
DonManfred Expert Licensed User Longtime User Mar 22, 2022 #5 Erel said: Where do you put this code? Click to expand... Based on the sub signature he is using it inside inline java or java i guess B4X: private static Map convertToMap(HashMap<?, ?> javaMap) { } Upvote 0
Erel said: Where do you put this code? Click to expand... Based on the sub signature he is using it inside inline java or java i guess B4X: private static Map convertToMap(HashMap<?, ?> javaMap) { }
EduardoElias Well-Known Member Licensed User Longtime User Mar 22, 2022 #6 Erel said: It will be easier to help if you provide more context. Where do you put this code? Based on the error it treats the Map as java.util.Map. Click to expand... thank you, Solved: B4X: import anywheresoftware.b4a.BA; import anywheresoftware.b4a.*; import anywheresoftware.b4a.objects.collections.*; import android.app.Activity; import android.content.Context; import java.util.HashMap; import java.util.List; public static Map convertToMap(HashMap<String, String> javaMap) { Map m = new Map(); m.Initialize(); for (HashMap.Entry<String, String> e : javaMap.entrySet()) { m.Put(e.getKey(), e.getValue()); } return m; } <more code> Upvote 0
Erel said: It will be easier to help if you provide more context. Where do you put this code? Based on the error it treats the Map as java.util.Map. Click to expand... thank you, Solved: B4X: import anywheresoftware.b4a.BA; import anywheresoftware.b4a.*; import anywheresoftware.b4a.objects.collections.*; import android.app.Activity; import android.content.Context; import java.util.HashMap; import java.util.List; public static Map convertToMap(HashMap<String, String> javaMap) { Map m = new Map(); m.Initialize(); for (HashMap.Entry<String, String> e : javaMap.entrySet()) { m.Put(e.getKey(), e.getValue()); } return m; } <more code>