+ 2
Error !
public class Program { public static void main(String[] args) { String s = "admin"; byte[] bytes = s.getBytes("US-ASCII"); } } // Shows an error :- An exception must be caught and thrown..... What should I do?
2 Answers
+ 14
Surround the line
byte[] bytes = s.getBytes("US-ASCII");
with a try / catch statement for the exception that is specified in the error message.
(throws annotation doesn't make sense here as it is the main class, you need to handle the exception).
+ 3
Oh thanks @ Tashi