File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assign flaot array object to ref of type Object
 
Similar Threads
Thread and Object
generics - why does this work?
Array
MultiDimenaional Array sort
WA #1.....word association