Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Assign flaot array object to ref of type Object  RSS feed

 
Shrikant Pandhare
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does this expression mean

Object oa = new float[20];
 
Alejandro Montenegro
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are initializing an array that contains 20 primitive values of float in the reference variable oa ...
 
Shrikant Pandhare
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But how can i use oa now... or how to access those float elements
 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will need to cast the reference variable back to an array of primative float values as follows:

float[] myArray = (float[]) oa;

Cheers.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!