class Example { 
  public static void main(String[] args) { 
    String p = "[^x&&[^\n]]"; 
    test(p, "x", false); 
    test(p, "y", true); 
    test(p, "\n", false); 
  } 

  private static void test(String p, String i, boolean e) { 
    if (java.util.regex.Pattern.compile(p).matcher(i).matches() != e) { 
      throw new AssertionError(); 
    }
  } 
} 