0

System.exit( )

what is System.exit( ) method? I seen example code: class program{ public static void main(String[ ] args){ int x=0; System.exit(); System.out.println(“1”); }} Here output is : error How does it work....

14th May 2020, 4:27 PM
Haritha Vuppula
Haritha Vuppula - avatar
4 Réponses
+ 2
Indian Yes. If a method expects arguments than you have to use them when calling this method.
14th May 2020, 5:41 PM
Denise Roßberg
Denise Roßberg - avatar
+ 4
Hello Indian int x = 0; int not Int System.exit() expects an integer as argument. Normal exit: System.exit(0); About this method: https://www.baeldung.com/java-system-exit System.out.println("1") vs. System.out.println(“1”); It is hard to see but in your code you are not using the normal "". Your code uses this characters: \u201c and \u201d so you get an illegal character error. Btw: Because of the exit your last print statement is dead code.
14th May 2020, 5:08 PM
Denise Roßberg
Denise Roßberg - avatar
0
thank you😊 Denise Roßberg and it is compulsary to pass integer argument in System.exit( ) ? without we get error ryt...
14th May 2020, 5:25 PM
Haritha Vuppula
Haritha Vuppula - avatar
14th May 2020, 5:45 PM
Haritha Vuppula
Haritha Vuppula - avatar