OK so what would I need to change to the following code so it would produce the following:

xxx
xoo
xoo

As at the moment it is producing:

xxxooo
xxxooo
xxxooo

My code that I have used can be seen below:

import javax.swing.*;
public class test {
    public static void main(String[] args){

        int row; 

        String num = JOptionPane.showInputDialog("Input?");

        row = Integer.parseInt(num);
        for(int i = 0; i < row; i++){  
            for(int j = 0; j < row; j++){
                System.out.print("X");
            }
            for (int z = 0; z < row; z++){
                System.out.print("O");
        }
        System.out.println("");
    }
}
}

What are the rules for what is printed on each line?

The simplest way:
System.out.println("xxx\nxoo\nxoo");

If you have to keep the for loop. Consider the code below.

for(int i = 0; i < row; i++){  
    for(int j = i; j < row; j++){
        System.out.print("X");
    }
    for (int z = 0; z < i; z++){
        System.out.print("O");
    }
    System.out.println();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.