Search code examples
javaarrayssuffix-array

Suffixing the each member of a Java Array of String


Suffixing of each array member by the same suffix (.wav) is required as:

String []  a = {"one", "two", "three"};
String str = ".wav"

Required output :

String[] a ={"one.wav", "two.wav", "three.wav"};

I tried to achieve this in the following way:

int m;

     for (m=0; m<a.length ;) {

        a[m]= a[m] +str  ;

     }

but I failed. What should I do to achieve the required output?


Solution

  • You forgot m++;

    for (m=0; m<a.length; m++) {
    
        a[m]= a[m] + str;
    
     }