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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Assign flaot array object to ref of type Object
 
Similar Threads
generics - why does this work?
MultiDimenaional Array sort
Thread and Object
WA #1.....word association
Array