This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Syntax for mapping a var to a method

 
Vinicius Souza
Ranch Hand
Posts: 70
1
Chrome Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends! Im trying to know about mapping a method to a attribute like in delphi do. I tryed to ask this question in another foruns and noone answered this question see an example:

Its works perfectly but what I want is something like this:


I know that this syntax doesnt exists in Java but there are something like this?
Thanks in advance!
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both your code examples are not valid Java syntax. You would do it like this:

I'm not sure what you want to do, I don't know Delphi.
 
Vinicius Souza
Ranch Hand
Posts: 70
1
Chrome Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:Both your code examples are not valid Java syntax. You would do it like this:

I'm not sure what you want to do, I don't know Delphi.

Yes, the first code is valid! Im using a inline class. But its not the problem. THe problema is what I trying to explain. Please someone else?
 
Stephan van Hulst
Bartender
Pie
Posts: 4838
34
Chrome Netbeans IDE Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like the poster is referring to properties. No, Java does not support properties. It's a pity, but you'll have to work with plain old methods.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vinicius Souza wrote:
Yes, the first code is valid!


No, it's not.

Im using a inline class.


You're close, but it's not quite correct.

 
Vinicius Souza
Ranch Hand
Posts: 70
1
Chrome Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote:
Vinicius Souza wrote:
Yes, the first code is valid!


No, it's not.

Im using a inline class.


You're close, but it's not quite correct.


Yes you are right. I created this code just to explain the topic. Corrected now. (I think) Something about the @topic ?
 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan gave you the answer: Java doesn't support properties, so you can't get what you want.
 
Vinicius Souza
Ranch Hand
Posts: 70
1
Chrome Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Brown wrote:Stephan gave you the answer: Java doesn't support properties, so you can't get what you want.

Thanks guys. For me java is the best language created but its 99.1% of perfection because doest have this feature. Thanks to all.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic