Ok I feel really dumb asking this but I seem to be missing something really simple here. I have the following code in a class in my service layer –
public Items getItems(String category, float amount, String color,
String type)
The code reads from a database and returns the results – I plan on placing it in a jframe. Nice and simple. But no matter how I call it from the jframe I get errors in eclipse that the code is wrong – either that their are illegal modifiers or such. So obviously I am calling it completely wrong, so my stupid question is how do you call that method into a jframe?
For example – if I try to call it this way:
public Items getItems();
I get told that getItems is an illegal parameter.
If I call this.. Items getItems(); I am told its undefined
Since you put some code up there, you are invoking the method wrong; what you have is not valid Java.
First you need to get an instance of your service.
MyService service = new MyServiceImpl();I’m assuming your service is defined as an interface (
MyService), with a class that implements the interface (MyServiceImpl).then you invoke the method on the instance
Items items = service.getItems(stuff);what you have
public Items getItems();is some sort of hybrid between a method definition and a method invocation.