Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-18-2008, 07:54 PM
Member
 
Join Date: Mar 2008
Posts: 31
masaka is on a distinguished road
How to reverse two dimensional
if i have a two dimensional array and want to make another arraythat is the reverse of the first array how to do this
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-19-2008, 03:06 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,022
hardwired is on a distinguished road
Code:
public class Test { public static void main(String[] args) { int[][] forward = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 } }; int rows = forward.length; int cols = forward[0].length; int[][] reverse = new int[rows][cols]; for(int i = rows-1; i >= 0; i--) { for(int j = cols-1; j >= 0; j--) { reverse[rows-1-i][cols-1-j] = forward[i][j]; } } for(int i = 0; i < rows; i++) { for(int j = 0; j < cols; j++) { System.out.print(reverse[i][j]); if(j < cols-1) System.out.print(", "); } System.out.println(); } } }
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-19-2008, 05:05 AM
Member
 
Join Date: Mar 2008
Posts: 31
masaka is on a distinguished road
thanks but how to make the colums rows and the rows colums without reversing
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-19-2008, 06:47 AM
Member
 
Join Date: May 2008
Posts: 1
asheesh_arora is on a distinguished road
Hi You can find the code at:

forum4everyone.com - How to transpose an array
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-19-2008, 11:02 AM
Member
 
Join Date: Mar 2008
Posts: 31
masaka is on a distinguished road
thanks alot for you
I love this site very much because there are many guys help me thanks to all of you

Last edited by masaka : 05-19-2008 at 11:12 AM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to initialize a two dimensional Array Java Tip java.lang 0 04-14-2008 09:48 PM
Data Modeler plug-in with Reverse Engineering feature? vpin3515 Eclipse 1 03-26-2008 12:41 PM
2 dimensional Lists gapper New To Java 4 01-20-2008 10:01 AM
Help with array multi-dimensional barney New To Java 1 07-31-2007 09:00 PM
Reverse engineer a java code lenny Advanced Java 1 07-26-2007 12:14 AM


All times are GMT +3. The time now is 04:11 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org