I'm new to Java and started a Spring application. However, when I instantiate a class in a different class and run a method the method does not output.
The class where the method is being called is SpringIn5StepsApplication.java and it looks like:
package com.example.springin5steps;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringIn5StepsApplication {
public static void main(String[] args) {
BinarySearchImpl binarySearch = new BinarySearchImpl();
int result = binarySearch.binarySearch(new int[] {12, 4, 6}, 3);
System.out.println(result);
SpringApplication.run(SpringIn5StepsApplication.class, args);
}
}
The BinarySearchImpl class looks like:
package com.example.springin5steps;
public class BinarySearchImpl {
public static void main(String[] args) {
}
public int binarySearch(int[] numbers, int numberToSearchFor) {
return 3;
}
}
As the binarySearch method is being called, the expected output is 3, but instead nothing is output when I run the program. What am I doing wrong and how can I get the 3 to output to IntelliJ?
runcall and you'll get exactly the same behavior.