Skip to main content
3 of 6
reformatted code to code. these lists are f*cking everything up
Vogel612
  • 25.3k
  • 7
  • 58
  • 141
  1. Looking at this code:

    if(strTemp.length() > maxWordLen)
             maxWordLen = strTemp.length();
    

    This could be reduced to:

    maxWordLen = Math.max(maxWordLen,strTemp.length());
    
  2. Inline the incrementation:

    charArr[i][j++] = ch;
    

Or just use System.arraycopy:

    char[][] charArr = new char[strArr.length][maxWordLen];
    for (int i = 0; i < strArr.length; i++) {
        System.arraycopy(strArr[i].toCharArray(), 0, charArr[i], 0, strArr[i].length());
    }
  1. Either inline the output:

    System.out.print((i != 0 ? " " : "") + charArr[i][j]);
    

    or at least place braces:

    if (i!=0){
       System.out.print(" ");
    }