• Post Reply Bookmark Topic Watch Topic
  • New Topic

Values are not being passed to Array  RSS feed

 
Marcus Rauchfuss
Ranch Hand
Posts: 51
1
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I have this class:




And as it is now, the values are not being passed into the shapeArray array.
If I "hard code" two shapes into the array in this class, everything works fine later on, but I do not manage to pass values into the array from the createShape() method. I tried several approaches, nothing works. Any hints? Thank you!
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marcus Rauchfuss wrote:And as it is now, the values are not being passed into the shapeArray array.

Which lines of the code do you think should be putting values into shapeArray ?
If you think the answer is lines 57 and 62, then you need to take a good look at them.
 
Mauro Trevigno
Ranch Hand
Posts: 99
Java Linux Tomcat Server
 
Marcus Rauchfuss
Ranch Hand
Posts: 51
1
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about this. I think I have a major berain glitch here, I have read the Array docunmentation myself previously, and I still come to the same conclusion, I would still code as I did. Yes, the values at line 57 and 62 should be passed, they are not.
This has to be a case of brain freeze on my part.

Could someone provide a code snippet that would be of help?


-------
EDIT:

(I am at the office now, so I cant't test this)

Hang on, is the answer instead of:

currentShape = shapeArray[1];


use

shapeArray[1]= currentShape; ?


If it is, please accept my facepalm.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that is the answer … if the question is
How do I assign elements into an array?
 
Marcus Rauchfuss
Ranch Hand
Posts: 51
1
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
*facepalm*

Thanks everyone. I take slight comfort in the fact it was almost midnight when I tried this yesterday.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everybody else here has made mistakes just as daft.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!