• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

setter and getter of multidimensional array  RSS feed

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have class test2 with an 3D array named as decision_variable. I define setter and getter for this array.I'm not sure is correct or not and then in the main class I want to set value for example  decision_variable [1][1][1]=1


 
Bartender
Posts: 678
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your setDecision_variables() method is declared to take a single input parameter, a 3-d int array.
You call it on line 31 passing "[1][1][1]=1" which is certainly not a legal 3D int array.

Your setDecision_variables() is declared as a method that takes no parameters and returns a 3D int array.
On line 32 you call it with the illegal syntax "[1][1][1]" as an argument, but declared it as a method that takes no arguments.

Perhaps you mean something like:
Note that this is probably not the best way to do things. A better way would be do declare the methods taking three indices:
and similarly for the setter.
Note that you should also check the validity of the indices passed.
 
Montana has cold dark nights. Perfect for the heat from incandescent light. Tiny ad:
ScroogeXHTML 8.2 - easy to use RTF to HTML converter library
https://coderanch.com/t/707504/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!