The index of an argument

Report a typo

Write a program that searches for an argument equal to "test" (without quotes), and then outputs its index in the array args. If it is not found, the program must output "-1". This argument can occur no more than once.

Please, do not rename the provided class Problem.

Sample Input 1:

arg1 arg2 test

Sample Output 1:

2

Sample Input 2:

arg1 arg2 arg3    

Sample Output 2:

-1
Write a program in Java 17
class Problem {
public static void main(String[] args) {

}
}
___

Create a free account to access the full topic