This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
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 Head First Android this week in the Android 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: 11811
    
  18

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: 43282
    
  32
Printing an array of arrays and printing a matrix are similar but not exactly the same.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java code to print 3 * 3 matrix
 
It's not a secret anymore!