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

Java Equivalent to C# Dictionary

The nearly exact Java equivalent to the .NET Dictionary collection is the HashMap collection.

C# Java
using System.Collections.Generic;

void Dictionaries()
{
    Dictionary<string, int> map = new Dictionary<string, int>();
    string s = "test";
    map.Add(s, 1);
    int i = map[s];
    i = map.Count;
    bool b = map.Count == 0;
    map.Remove(s);
}
void Dictionaries()
{
    java.util.HashMap<String, Integer> map = new java.util.HashMap<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.