File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes TypeCasting 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 » Java » Java in General
Bookmark "TypeCasting" Watch "TypeCasting" New topic
Author

TypeCasting

Chinmay Bajikar
Ranch Hand

Joined: Dec 08, 2001
Posts: 159
How heavy is a TypeCasting operation?
Especially when I am doing Object typecasting?
ex
String s = (String)vector.elementAt(0);
is efficient or
String s = vector.elementAt(0).toString();
is efficient.
Thanks in adv,
Bye,
Chinmay.


The strength of the Wolf is the pack & the strength of the pack is the wolf....Rudyard Kipling
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Casting is cheaper than most Method calls, but it has it's own set of problems.
You might want to read Java performance programming, Part 2: The cost of casting from JavaWorld


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
 
subject: TypeCasting
 
Similar Threads
sorting in vectors
(immediate)Vector Object conversion
vectors
Why i can't print this array?
String Operation