I have to write a program that would generate a matrix that should display the following output. They are asking that we dont hard code our values in this program. I am lost on how I will get these values to display without hard coding. My question is how should my expression look. Any information that you all can give me I would greatly appreciate it.

Instead of storing the values in an array, consider how you could compute each value from the loop index variables at the position you need to print it. For example, 2, 4, 6... could be (column + 1)*2, right? If you think a little about it, there's a pretty obvious equation that uses both "row" and "column" and computes the value of every cell in your matrix.

I suspect it's OK to hardcode the "5"'s, by the way -- the loop limits.

1) "" and " " aren't the same; the first is an empty String, the second has one space in it. You want to print spaces between your numbers, not empty strings.

2) The first loop doesn't have that extra "System.out.println()" after each iteration of the inner loop, so everything is on one line.

3) You need to come up with a single equation which uses both variables to compute each number, and then just use a single set of nested loops (since you only want to print one matrix!)

I made some minor modifications to get it to compile, and stuck in some print statements. try this code, and see if you can figure out what it's doing...

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors

Let's look at the first number in each row. See a pattern there? How does this relate to the row number?

Ok, now you have the first number. How do the rest of these numbers relate to that first number? See another pattern? And how does this relate to the column number?

Yes I see the pattern, for every number in the first row you add 2 then the next row you add 3 to each number then so on and so on. I know am missing something on trying to put this all into one equation. Am going to take a break and then come back and look at it again. To try to find what am missing.

hmmm... what can i use to easily get me those numbers, one after the other...

HEY!!! that kind of sounds like a for-loop might work. I can start my loop with any value i want, so starting it at 2 shouldn't be a problem. then, I just have to make sure I stop it before my counter gets to be 7.