• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with method between classes  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys, i'm new to the java language, so I met some difficulties undestanding a code line:



I need to generate classes and methods that allow to use that line of code. So i've 2 questions:

1. There's a way to use query<Diary>(diaries) as a method that returns an object (istance of a class with the method execute) without the syntax object.method() or class.method()?

Moreover, i could define this method within a class where I've to use that line of code, but i would use that line of code also in other classes.

2. There's an alternative way to call that method without the standard syntax?

Thanks a lot in advance.
 
Greenhorn
Posts: 26
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paolo Scire' Scappuzzo wrote:hi guys, i'm new to the java language, so I met some difficulties undestanding a code line:



I need to generate classes and methods that allow to use that line of code. So i've 2 questions:

1. There's a way to use query<Diary>(diaries) as a method that returns an object (istance of a class with the method execute) without the syntax object.method() or class.method()?

Moreover, i could define this method within a class where I've to use that line of code, but i would use that line of code also in other classes.

2. There's an alternative way to call that method without the standard syntax?

Thanks a lot in advance.


Hello Paolo, if I am understanding this correctly, you would like to invoke a method called execute(). Would you mind posting more code because it is difficult to gain insight of what you are trying to do with just one line of code. It also appears that you are not using Java because I've never seen the syntax object.method() or class.method() in Java unless someone knows something I have not learned yet.
 
Paolo Scire' Scappuzzo
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately, there's no more code because the target is to GENERATE a code that can be used in the following way:

I wanna know in which way I can call a method with this syntax: query<T>(param)

In general, in Java we can use a syntax like: istanceName.methodName(); or className.methodName() (the 2nd if methodName is a static method).

But i'm interested to understand how I can use directly methodName() between several classes.
 
Marshal
Posts: 56608
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
query<Diary>(...)?

That looks incorrect. Is there anything missing, because I think that code won’t compile in its present form?
 
Campbell Ritchie
Marshal
Posts: 56608
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where did this task come from?

this line can compile:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!