In Mendix, Right click->Add other->Java action→ Add parameters and return value as per your requirement.
Download an install eclipse
Open eclipse→ File->Open project from file system->Select your mendix project folder
In Mendix, Run->Deploy for Eclipse
In Eclipse, Right click your project name->Refresh
You will get your project in package explorer of eclipse
Open java source→ you can get all your java actions
Type your java code inbetween the start and end code
With Java actions you can extend the functionality of your application in situations where it would be hard to implement this functionality in microflows. You can call a Java action from a microflow using the Java action call.
Please go through the docs: https://docs.mendix.com/refguide/java-actions/
First you need to create the Java action by using Add other → Java action. Once its done open the java action and add the parameter as you want and return type parameter based upon your requirement.
Once its done deploy for eclipse and doo the java code in eclipse and call the java action were ever you needed in the microflow.
Attached the screenshot for reference.
In addition to the other answers you’d only need to use a Java Action if the functionality you need isn’t available directly in Mendix.
One example where you would need to do this would be to integrate a third party Java library and make its functions available to Mendix.
Most users wouldn’t need to write their own Java actions as the most common use cases would already have solutions available in the Mendix Marketplace to download. However, the ability for everyone write their own Java Actions means if the functionality isn’t available elsewhere, you can write your own solution.
Hope this helps.