permaculture playing cards*
The moose likes Beginning Java and the fly likes Java code to print 3 * 3 matrix Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java code to print 3 * 3 matrix" Watch "Java code to print 3 * 3 matrix" New topic

Java code to print 3 * 3 matrix

Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
I need java code to print 3 * 3 matrix . all numbers should be 3. i mean a[0,0]=3 ,a[0,1]=3 .......a[2,2]=3
3 3 3
3 3 3
3 3 3
Christophe Verré

Joined: Nov 24, 2005
Posts: 14687

Hi. After so many post, you still haven't checked HowToAskQuestionsOnJavaRanch ? First, CarefullyChooseOneForum. I'm moving this thread out of the servlets forum. Then ShowSomeEffort, DoYourOwnHomework and NotACodeMill.

[My Blog]
All roads lead to JavaRanch
Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
Rajendra Prakash,

I'm guessing you can't just do:

Try using loops (for, while, do/while).

I no good English.
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11155


Please refrain from simply handing out a solution of any kind. We want people to learn how to write code themselves, not copy from other people (which is potentially illegal and against every school's code of conduct).

Giving hints is fine, but no actual solutions.

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

Joined: Sep 16, 2008
Posts: 241
fred, I didn't mean to give away a solution. I presumed, due to square brackets, that an array needs to be printed out. I will try to be more carefull in the future.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 37990
Printing an array of arrays and printing a matrix are similar but not exactly the same.
It is sorta covered in the JavaRanch Style Guide.
subject: Java code to print 3 * 3 matrix
Similar Threads
print in matrix printer
Java code for 3Dimensional Array
About Constructor Chaining
2 dimensional array without hard coding values