Guest User

Untitled

a guest
Mar 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. public @interface Rule {
  2. static int count = 0;
  3. String name();
  4. String description(); //Note the parentheses
  5.  
  6. public Rule(String name, String description) {
  7. count++;
  8.  
  9. this.name = name;
  10. this.description = description;
  11. }
  12. }
  13.  
  14. public class Airline {
  15. private String code;
  16.  
  17. @Rule(name = "Formatted Code", description = "e.g. Format 'la' as 'LA'")
  18. public String codeFormatted() {
  19. return code.toUpperCase();
  20. }
  21.  
  22. public static void main(String args[]) {
  23. System.out.println(Rule.count);
  24. }
  25. }
  26.  
  27. javac Rule.java
  28. Rule.java:6: error: <identifier> expected
  29. public Rule(String name, String description) {
  30. ^
  31. 1 error
  32.  
  33. Compilation exited abnormally with code 1 at Thu Mar 22 19:58:39
Add Comment
Please, Sign In to add comment