Advertisement
cd62131

ContainsA

Mar 7th, 2014
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.44 KB | None | 0 0
  1. public class ContainsA {
  2.   public static void check(String str) throws Exception {
  3.     if (str.contains("a")) throw new Exception("Found \"a\".");
  4.   }
  5.  
  6.   public static void main(String[] args) {
  7.     try {
  8.       check("ccc"); System.out.println("ccc is OK.");
  9.       check("bbb"); System.out.println("bbb is OK.");
  10.       check("aaa"); System.out.println("aaa is OK.");
  11.     }
  12.     catch (Exception e) {
  13.       e.printStackTrace();
  14.     }
  15.   }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement