This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assign flaot array object to ref of type Object
 
Similar Threads
MultiDimenaional Array sort
WA #1.....word association
generics - why does this work?
Thread and Object
Array