This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Get Programming with Java (MEAP only) and have Peggy Fisher on-line!
See this thread for details.
Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!
  • 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
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

setter and getter of multidimensional array  RSS feed

 
Greenhorn
Posts: 28
  • 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: 639
9
  • 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.
 
Eliminate 95% of the weeds in your lawn by mowing 3 inches or higher. Then plant tiny ads:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!