aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java code to print 3 * 3 matrix" Watch "Java code to print 3 * 3 matrix" New topic
Author

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é
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

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). http://java.sun.com/docs/books/tutorial/java/nutsandbolts/for.html


SCJP 6, OCMJD 6, OCPJWSD 6
I no good English.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11412
    
  16

Martin,

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
Sheriff

Joined: Oct 13, 2005
Posts: 39409
    
  28
Printing an array of arrays and printing a matrix are similar but not exactly the same.
 
Don't get me started about those stupid light bulbs.
 
subject: Java code to print 3 * 3 matrix