I'm new and trying to draw a table type where I can place scores inside like 5;

    A     B    C

1 5//this is where it all falls apart


I have this so far but not working;

public class Table3 {
    static int[][] list = new int[4][4];
    //private char column = 'A';
    //private int row = 1;
    private static int row = 1;
    public Table3(){
        //column = 'A';
        for (int i = 0; i < 4; i++) {  
            for (int j = 1; j < 4; j++)
                list[i][j] = 0;
       public static void table(char col, int row, int value) {
            System.out.printf("\n\n%s\n", "Table");
       for (int i = 1; i < 4; i++) {//System.out.print(row2 + "     ");
                for (int j = 1; j < 4; j++)//System.out.print(column + "     ");System.out.println("\n");row2++;column++;
                    if (row >= 0 && row <= 4 && col >=0 && col <= 4) 


public class TableTest {
public static void main(String[] args) {
        // TODO Auto-generated method stub
        Table3 t = new Table3();
        Table3.table('A', 5, 5);

Any help would be appreciated.

Recommended Answers

All 7 Replies

try to replace this:

// TODO Auto-generated method stub
Table3 t = new Table3();
Table3.table('A', 5, 5);

with this one:

// TODO Auto-generated method stub
Table3 t = new Table3();
t.table('A', 5, 5);

The issue is not client code by any means. I meant t.table('A', 5, 5); the issue is that it's not printing the value inside the array/matrix. Thanks

it is not printing, because you have condition here:

if (row >= 0 && row <= 4 && col >=0 && col <= 4)

while you called table with parameters ('A', 5, 5) so the condition will never true, try:

t.table(3, 3, 'A');

also, you have to change this one, because it's not make sense

public static void table(char col, int row, int value)


public static void table(int col, int row, char value)

and the way you printing, should be like this

if (row >= 0 && row < 4 && col >=0 && col < 4)

because in your variable list, you only asigned until index 3.

commented: Good contribution, even if the OP is too conceited to recognise it +15

Dude...... please....give up.....most people know java 101....this is not about not knowing how to call a rotten method....please.....this is not simple.....I had a university phd stuck on this. the print method is overriding...and that's a problem....please...pros only

albedini: please be polite. Old Apache is trying to help you. The very first sentence of his previous post explains why your print produces nothing with those call parameters. What is it about that explanation that you do not understand or think is irrelevant?

Sorry for going overboard, I'm new to forums. Regardless of anyone says, it's human nature to shy away from a post that has been replied to with some code! I mean why waste time with a question that has already been answered? If nothing else, replies-for-quick-points can delay the time it takes to get a solid solution! I can't find old apache's first reply but I felt that it could close down my question. His second reply just expanded on his first unrelated reply. So now I have two unrelated replies from a person that has never been able to solve any problems! To me this is just another form of trolling! I personally would never even dare answering a question without at least compiling a code to see where the problem lies. Unless I have a ton of solutions under my belt anyway. Just readin the code and nitpicking the first typo is not the way to handle complex questions. Especially since I made specific comments about where the problem is. I think these types of replies chase away people with good questions and answers!

I also "just read the code", and it's a shambles, full of obvious mistakes. No need to compile it.
Old Apache took the time to point out some of the more obvious ones. Maybe confusing an instance variable with a class name was "just a typo", but how was anyone to know what you really meant - we can only comment on the code you post.
The second blunder - passing values of 65,5,5 to a method that only does anything with values <4 - was the subject of OA's second post, which it seems you still don't understand.
You're lucky he didn't get into the overall logic of your method. Despite its meaningless name, I cannot believe that it is supposed to assign a value to the same array element 16 times and print out that same value 16 times.
Or... you pass a char value of 'A' (decimal 65) to use as an array index for an array of size 4. My best guess is that you got the order of the parameters confused - which was also discussed by O.A. - or maybe you are mistaken in your understanding about using chars for array indexes?
And as for why you create an instance of a class that has no instance members, then use the constructor to initialise a static array to the same values that Java has already initialised it to...

You asked for help with code that needs a great deal of help. People here are trying to help. If you're not comfortable with that then stop criticising the helpers and move on.

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.