I'm new to java..I want to show a table in my GUI. I know there are several questions like this but that didn't help me. Any help would be appreciated.

**Test.java**

```
package test;

import javax.swing.*;
import java.awt.*;

    class Test {

        JFrame frame;
        JTable table;
        Container pane;

        public void initGUI () {
            frame = new JFrame("Table");
            frame.setLayout(null);
            frame.setVisible(true);
            frame.setBounds(100, 100, 500, 500);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            pane = frame.getContentPane();

            Object[][] rows = {
                {"Amir", "Karachi"},
                {"Noman", "Quetta"},
                {"Salman", "Rawalpindi"}
            };
            Object[] cols = {"Name", "City"};

            table = new JTable(rows, cols);
            pane.add(new JScrollPane(table));
        }

        public static void main (String args[]) {
            Test obj = new Test();
            obj.initGUI();
        }

    }

```