aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Assign flaot array object to ref of type Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Assign flaot array object to ref of type Object" Watch "Assign flaot array object to ref of type Object" New topic
Author

Assign flaot array object to ref of type Object

Shrikant Pandhare
Greenhorn

Joined: Jul 29, 2005
Posts: 15
What does this expression mean

Object oa = new float[20];
Alejandro Montenegro
Greenhorn

Joined: Jul 05, 2004
Posts: 29
You are initializing an array that contains 20 primitive values of float in the reference variable oa ...
Shrikant Pandhare
Greenhorn

Joined: Jul 29, 2005
Posts: 15
But how can i use oa now... or how to access those float elements
Marcelo Ortega
Ranch Hand

Joined: May 31, 2005
Posts: 519

You will need to cast the reference variable back to an array of primative float values as follows:

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

Cheers.


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD, SCEA/OCMJEA

Live life to an interface, not an implementation!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Assign flaot array object to ref of type Object