Questions tagged as 'try-catch'

2
answers

Try - Catch and Variable not initialized

I just learned the basic structure of the Try-Catch and I made a small code to test it, but it gives me an uninitialized variable error. Can someone instruct me a little about this? I leave the code: public static void main(String[] args) {...
asked by 22.03.2018 / 05:45
4
answers

Does the finally block always run in Java?

I have a try / catch with a return inside. Will the block finally be executed? try { something(); return success; } catch (Exception e) { return failure; } finally { System.out.println("No se si esto se va a im...
asked by 01.12.2015 / 23:07
10
answers

Force jump to catch

Is there any way to force the jump, without causing an exception, from inside try to catch ? For example: try { // Código // ... // //Provocar salto al "catch" -> ¿otra opción? Integer.parseInt( "hola" ); } catch(...
asked by 19.12.2016 / 20:02
4
answers

return error message with "Throw Exception" or "Return"?

Hello, the question arose to me, which is the best way to return a message in the event of an error? Throw Exception: try { ....... return cargarPersonas; } catch(Exception e) { throw new Exception("Mensaje.", e); } Return: try...
asked by 28.09.2016 / 22:45
4
answers

Problem with NumberFormatException and showInputDialog

My problem is that I have a window JOptionPane.showInputDialog that receives a data of type int . I wanted to do a try-catch to handle the exception NumberFormatException if they put a letter instead of a number. The p...
asked by 19.03.2017 / 00:00
2
answers

Error message in c ++

These are the methods of my program, when I divide between 0 the error message is printed and then if they print a series of random numbers (I understand the cout of the main is not executed correctly) What is the best way to check that Do not d...
asked by 17.10.2018 / 18:27
2
answers

Is it possible to capture a segfault with try / catch?

To check if it is possible I did the following: try { int *x = 0; *x = 1234; } catch(...) { cout << "OK"; } But when I run it, I get a segfault in the same way. I've read in some sites that try / catch can not capture a se...
asked by 20.10.2016 / 04:20
3
answers

Collect several exceptions from a try / catch in Java

I have a try/catch in my code. Inside the try I have different validations, each one throws an exception type that in turn extends the "general exception" parent class: GENERAL EXCEPTION public abstract class GeneralException exten...
asked by 04.12.2018 / 15:15
1
answer

Doubt between try-catch and throws

When I write .start () in the code to indicate that the process starts, the Eclipse program gives me an error and gives me two options: wrap the .start () in a try-catch block or add a throws to the class. What is the difference between using a...
asked by 28.05.2018 / 01:02
2
answers

Caught in the try catch [duplicate]

Pressing a button on my program is always caught in catch The error that I get when executing the program is as follows E/editarcontacto: null java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.util.Arra...
asked by 14.11.2018 / 13:36