Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Assign flaot array object to ref of type Object

 
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic