aspose file tools*
The moose likes Beginning Java and the fly likes Syntax for mapping a var to a method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Syntax for mapping a var to a method" Watch "Syntax for mapping a var to a method" New topic
Author

Syntax for mapping a var to a method

Vinicius Souza
Ranch Hand

Joined: May 18, 2011
Posts: 45

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!


Java is the best (I love C too) heehhh
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14150
    
  18

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Vinicius Souza
Ranch Hand

Joined: May 18, 2011
Posts: 45

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

Joined: Sep 20, 2010
Posts: 3647
    
  16

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

Joined: Jan 03, 2004
Posts: 6109
    
    6

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

Joined: May 18, 2011
Posts: 45

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

Joined: Apr 06, 2010
Posts: 4391
    
    8

Stephan gave you the answer: Java doesn't support properties, so you can't get what you want.
Vinicius Souza
Ranch Hand

Joined: May 18, 2011
Posts: 45

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
 
subject: Syntax for mapping a var to a method