
read two arguments from the command prompt.if the no.of arguments are not equalto two,throw a user defined exception "invalid parameter exception" ,otherwise display the two parameters.

Here is an example that accepts two arguments from the user. If the number of arguments is not equal to two then invalid parameter exception is thrown ,otherwise display the two arguments.
import java.util.*;
class InvalidParameterExceptionExample
{
public static void main(String[] args)throws Exception
{
for (String s: args) {
if(args.length==2){
System.out.println(s);
}
else{
throw new Exception("Invalid Parameter Exception");
}
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.