• Post Reply Bookmark Topic Watch Topic
  • New Topic

unnecessary cast?  RSS feed

 
Ranch Hand
Posts: 63
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In line 2, why is there a cast on method rs.getMetaData() when the return type is already a ResultSetMetaData type?
The code ran fine when I removed the cast, so I'm wondering if there is an 'advanced' reason for the cast.

 
Ranch Hand
Posts: 136
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

I think the cast is not necessary.

Where did you get this code from? Is the author using a specific jdk version?
 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Nachreiner wrote:The code ran fine when I removed the cast, so I'm wondering if there is an 'advanced' reason for the cast...

Nope. Indeed, the docs for the class specifically show an example without one.

Winston
 
Tim Nachreiner
Ranch Hand
Posts: 63
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Balagopal Kannampallil wrote:

Where did you get this code from? Is the author using a specific jdk version?


Most of my sample code for JTable comes from Oracle's jdk6 site. I'm not 100% sure that's where this came from.
 
Balagopal Kannampallil
Ranch Hand
Posts: 136
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No worries!!
I was curious to know where this piece of code came from.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!