Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Java programs are not able to run or save

iam unable to run or save the program in the java. And there are no options to save the program. may i know the reason for that.
by

2 Answers

iamabhishek
Hi, can you please share the code that you were trying to execute so that we can investigate.
Prasannajpy0e
importjava.util.InputMismatchException;
importjava.util.Scanner;
publicclassMphasis{
publicstaticvoidmain(String[]args){
Scanners=newScanner(System.in);
System.out.println("enteranumber:");
intn=s.nextInt();
if(n<0){
thrownewInputMismatchException("Thenumbershouldnotbenegative");
}
System.out.println(factorial(n));
}
privatestaticintfactorial(intn){
if(n==1||n==0){
return1;
}
returnn*factorial(n-1);
}
}

Login / Signup to Answer the Question.