I found an interesting thing here. This is not a problem, I'm just interested to know about the priority order. Go to the code:
I have two methods in one class:
1- public void method1(String a, String...b){
2- System.out.println(a + "===" + b[0]);
3- }
4-
5- public void method1(String a, String b){
6- method1(a, b);
7- }
8-
9- public static void main(String[] args) {
10- Teste t = new Teste();
11- t.method1("a", "b");
12- }
Performing the tests here, I see that the call method1on line 11 will call method1, defined on line 5, then it will make self-language, so a java.lang.StackOverflowError. My question is about calling the priority order for these methods, since method1in line 1 it gets String, String[]and method1in line 5 it gets String, Stringin theory, they get the same parameters if I want to pass only one line for the second parameter for both methods.
I know that in this scenario, to call a specific method on line 1 with one line as the second parameter, I would need to do method1("someString", new String[]{"someString"});
, - ( ) . - :
" , , - , , , , , ,