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


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
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: 70
    
    1

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: 15002
    
  27

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 8 API documentation
Vinicius Souza
Ranch Hand

Joined: May 18, 2011
Posts: 70
    
    1

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: 4101
    
  19

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.


The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
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: 70
    
    1

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: 4541
    
    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: 70
    
    1

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
 
jQuery in Action, 3rd edition