• Post Reply Bookmark Topic Watch Topic
  • New Topic

Additional Use for Parentheses.  RSS feed

 
Eden Landau
Ranch Hand
Posts: 40
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello! I came across this bit of code the other day.
Can anyone tell me what role do the oddly placed parentheses in line 67 play?
Thank you all very much!

 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean this line?

The (JButton) is a type cast. It means that the compiler should treat whatever object e.getSource() returns as if it is a JButton object.

There's some information about type casting on this page from Oracle's Java Tutorials.
 
Eden Landau
Ranch Hand
Posts: 40
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That solves it then! Thank you very much!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!