[java] I need to know how to get my program to output the word i typed in and also the new rearranged word using a 2D array

I have a working program which takes the first letter of a word then switches it to the back of the word and adds "ay to the end. It works fine but I am trying to store the original word and the newWord in a 2D array and output all contents of the array. I have tried but have come to a dead end.

import javax.swing.JOptionPane;  public class Decoder1App{     public static void main(String[]args){          String word="";         String newWord="";         String log[][] = new String[3][2];          for(int i=0;i<log.length;i++){             for(int j=0;j<log[i].length;j++){                Decoder1 D1 = new Decoder1();`enter code here`                 word = JOptionPane.showInputDialog(null,"Please enter your word");                 D1.setWord(word);                 D1.compute();                 newWord=D1.getNewWord();              }         }          JOptionPane.showMessageDialog(null,"The new word is " + newWord);    } } 

This question is related to java

The answer is


  1. What exactly doesn't work?
  2. Why are you using a 2d array?
  3. If you must use a 2d array:

    int numOfPairs = 10;  String[][] array = new String[numOfPairs][2]; for(int i = 0; i < array.length; i++){     for(int j = 0; j < array[i].length; j++){         array[i] = new String[2];         array[i][0] = "original word";         array[i][1] = "rearranged word";     }    } 

Does this give you a hint?