Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about section of the Oracle Java Tutorials regarding interfaces

 
simon fletcher
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The examples on this page of the Oracle Java Tutorials have some examples like

There are two other similar examples and each of them have the line

Why is obj1 in brackets? By the way I don't mean the brackets that relate to the if statement. I mean the ones that directly surround obj1, as in (obj1). Is it just a typo? I don't recall seeing this kind of thing before.

Thanks for taking the time to look at this.
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's just a way someone is used to write code. In this case there would be no difference if you omit those around obj1. Take a look at this:

Both statements produce same output. It's just a matter of coding style.
 
simon fletcher
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess then it's nothing more than if someone wrote a math statement like (23)*46. The brackets don't do anything. They get ignored by the compiler.

Thankyou.
 
Winston Gutkowski
Bartender
Pie
Posts: 10417
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
simon fletcher wrote:I guess then it's nothing more than if someone wrote a math statement like (23)*46. The brackets don't do anything. They get ignored by the compiler.

Actually, they don't get ignored; it's just that in this situation, they don't do anything. If you wrote (23+1)*46, they most certainly would.

Winston
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic