• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Syntax for mapping a var to a method

 
Ranch Hand
Posts: 86
1
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 86
1
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Saloon Keeper
Posts: 15489
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 86
1
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 86
1
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic