System.exit( ) | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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 Respostas
+ 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