79073603

Date: 2024-10-10 09:15:41
Score: 1
Natty:
Report link

I tried below code and its working Lets say we need total length of string after adding space in between is 12.

    String str1 = "Rohit", str2 = "BHA";
    String finalString = str1;
    for(int i = 1 ; i <= 12 - str1.length() - str2.length() ; i++)
    {
        finalString += " ";
    }
    finalString += str2;
    System.out.println("iban curr : "+finalString);

Now finalString have value : "Rohit BHA" (4 space in between)

Reasons:
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: rushabh