I'm new to Java. I want rewrite some Python code to Java to achieve basically the same functions. One part in my Python code is to execute the functions in sequence. Can I create a similar collection of methods in Java?
process_workflow.py
workflow = [
stage1,
stage2,
stage3
]
def process_workflow(workflow: list):
for stage in workflow: # each 'stage' is a method
stage()
The methods of each stage are defined in another Python script. stages.py
def stage1():
...
def stage2():
...
def stage3():
...
My tentative Java code:
class Stages {
void stage1() {
}
void stage2() {
}
void stage3() {
}
}
class Main {
public static void main(String[] args) {
Stages stage_obj = new Stages();
Collection workflow = new ArrayList();
workflow.add(stage_obj.stage1);
workflow.add(stage_obj.stage2);
workflow.add(stage_obj.stage3);
Iterator workflowIterator = workflow.iterator();
// ...
}
}