This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TypeCasting

 
Chinmay Bajikar
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic