Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ContainsA {
- public static void check(String str) throws Exception {
- if (str.contains("a")) throw new Exception("Found \"a\".");
- }
- public static void main(String[] args) {
- try {
- check("ccc"); System.out.println("ccc is OK.");
- check("bbb"); System.out.println("bbb is OK.");
- check("aaa"); System.out.println("aaa is OK.");
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement