Win a copy of Design for the Mind this week in the Design 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