0

I want to pass void parameter to another void method. For example;

public void WriteItem(ParameterItem())
{
System.out.println("1");
ParameterItem();
System.ou.println("2");
}

//In Another Class
public void ParameterItem()
{
System.out.println("ABC");
}

I want this: 1 ABC 2

grkemaykac
  • 13
  • 1
  • 4
  • 1
    Wouldn't it be easier to make `ParameterItem()` (or `parameterItem()` for proper naming) return the value you want it to print, rather than having the printing functionality built in? – Kayaman Dec 23 '21 at 08:54
  • Does this answer your question? [How to pass a function as a parameter in java](https://stackoverflow.com/questions/48594418/how-to-pass-a-function-as-a-parameter-in-java) – Amir M Dec 23 '21 at 08:58
  • Check this https://stackoverflow.com/a/4685606/2400380 – Amir M Dec 23 '21 at 08:58
  • ParametersItem is void method thats return nothing – grkemaykac Dec 23 '21 at 10:03

0 Answers0