• Saves Valuable Time
  • Trusted Accuracy for 12 Years
  • 15-Day Money-Back Guarantee

Java Equivalent to C++ std::map

The nearly exact Java equivalent to the C++ std::map collection is the Java TreeMap collection.

C++ Java
#include <string>
#include <map>

virtual void Map()
{
    std::map<std::wstring, int> map;
    std::wstring s = L"test";
    map[s] = 1;
    int i = map[s];
    i = map.size();
    bool b = map.empty();
    map.erase(s);
}
void Map()
{
    java.util.TreeMap<String, Integer> map = new java.util.TreeMap<String, Integer>();
    String s = "test";
    map.put(s, 1);
    int i = map.get(s);
    i = map.size();
    boolean b = map.isEmpty();
    map.remove(s);
}


Use C++ to Java Converter to convert from C++ to Java.     

Additional resource: Java and C++ Equivalents


Copyright © 1997 – 2017 Tangible Software Solutions Inc.