Unreported exception java.lang.exception : Must be caught or declared to be throw. Why this problem will occur? Is it some simple method that can help to solve this problems
1. There are 2 ways to handle the exception.
- Either `declare` it
- or `Handle` it.
2. encrypt()
method above throws an Exception
So either declare it on the method declaration in which you are calling it.
eg:
public void MyCallingMethod() throws Exception{
byte[] pass = encrypt(password);
String pw = new String(pass);
}
Or handle it with try/catch
block, finally
is optional
try{
byte[] pass = encrypt(password);
String pw = new String(pass);
}catch(Exception ex){
}