This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of DevSecOps Adventures: A Game-Changing Approach with Chocolate, LEGO, and Coaching Games and have Dana Pylayeva on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

2 dim array

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello ranchers
I was trying to do some experiment on multi dim array
I will let you all know that i am trying to add values of 2 multi dimensional array in a method and the return type of that method is a 2 dimensional array i am expecting s[ome]thing different but the output wat i am getting is s[ome]thing else pl[ease] help me here is the code


[HENRY: Removed unnecessary code tags and got rid of illegal abbreviations]
[ January 15, 2007: Message edited by: Henry Wong ]
 
Ravi Ahuja
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


[op]
i am expecting the output as
2
4
6
8
10
12
14
16
18
[/op]
[ap]
but the output is
2
4
8
10
please help me to get the output as mentioned above thank you
[/ap]
 
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


It's your for loop -- you are not iterating through all the members.

Henry
 
Ravi Ahuja
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry sir didnt understood can you elaborate this please
Thank You


(removed code tags and spelled out "you" correctly)
[ January 15, 2007: Message edited by: Barry Gaunt ]
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What Henry want you to do is to look at the for loops where you are printing the array. The upper limits of the loops are incorrect. "j<arr[0].length-1" should be "j<arr[0].length". The same thing holds for the outer for loop.

You can also print your arrays like this:

[ January 15, 2007: Message edited by: Barry Gaunt ]
 
Henry Wong
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you have some time, please read this. It is far easier to "use real words" than to circumvent the posting checker.

Henry
 
Ravi Ahuja
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[c]
Thanks Henry that clears my doubt
Thank you..!!
[/c]
 
Live ordinary life in an extraordinary way. Details embedded in this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic