Hej,
Mama taki kod:
Map<String, String> conjugatedForms = new HashMap<>();
conjugatedForms.put("yo/I", null);
conjugatedForms.put("tú/You", null);
conjugatedForms.put("él, ella, Ud./He/She/It", null);
conjugatedForms.put("nosotros/We", null);
conjugatedForms.put("vosotros/You", null);
conjugatedForms.put("ellos, ellas, Uds./They", null);
if (word.endsWith("ar"))
{
for (String ending : endingsAr)
{
String root = word.substring(0, word.length() - 3);
String conjugatedVerb = root + ending;
for (Entry<String, String> entry : conjugatedForms.entrySet())
{
conjugatedForms.putIfAbsent(entry.getValue(), conjugatedVerb);
}
}
}
System.out.println(conjugatedForms);
Jak dodać do kluczy wartości?
Same wartości zależą od tego, co wprowadzi użytkownik.
Gdześ na StackOverflow czytałem, że nie jest dobrą praktyką ustawiać wartośći na null,
ale nie mam pomysłu jak to zrobić zgrabnie.
Macie jakieś podpowiedzi?
Cała koncepcja jest zła?
Pozdrawiam