Tangible Software Solutions

The Most Trusted Name in Source Code Conversion

  • Trusted for over 12 Years
  • Saves Valuable Time
  • Accurate and Reliable
  • Responsive Support

Java Equivalent to C# Dictionary

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

Original C#:

void Dictionaries()
{
   Dictionary<string, int> myDictionary = new Dictionary<string, int>();
   string s = "test";
   myDictionary.Add(s, 1);
   int i = myDictionary[s];
   i = myDictionary.Count;
   bool b = myDictionary.Count == 0;
   myDictionary.Remove(s);
}

Equivalent Java:

void Dictionaries()
{
   java.util.HashMap<String, Integer> myDictionary = new java.util.HashMap<String, Integer>();
   String s = "test";
   myDictionary.put(s, 1);
   int i = myDictionary.get(s);
   i = myDictionary.size();
   boolean b = myDictionary.isEmpty();
   myDictionary.remove(s);
}

If you need to convert from C# to Java and you are depending on the results being reliable and accurate, then you will want to have C# to Java Converter, the best C# to Java converter, at your fingertips.

Copyright © 1997 - 2017 Tangible Software Solutions Inc.