Home > Software design >  Using (String.format)
Using (String.format)

Time:07-03

hashMap2.put("msg", mUsername " joined");

While like this I want to do it like this but it doesn't work

hashMap2.put("msg", String.format(mUsername, context.getString(R.string.joined)));

CodePudding user response:

I assume that you want something like that:

hashMap2.put("msg", String.format("%s %s", mUsername, context.getString(R.string.joined)));

And if you are using Java 17:

hashMap2.put("msg", "%s %s".format(mUsername, context.getString(R.string.joined)));

CodePudding user response:

Unfortunately it didn't work in Turkish (%s joined) but it should be in English (joined %s)

  •  Tags:  
  • java
  • Related