Created
February 21, 2016 17:59
-
-
Save ip-imamoto/b17bb17affc3fe45670e to your computer and use it in GitHub Desktop.
アノテーションの使い方
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package myannotation; | |
public class MyAnnotationTest { | |
@MyAnnotation | |
public String hoge; //←valueの値の指定をしていないのでデフォルト値 | |
@MyAnnotation(value = "コンストラクタ!!!") //←値を指定 | |
public MyAnnotationTest(String hoge) { | |
this.hoge = hoge; | |
} | |
@MyAnnotation("メソッド!!") //←キー名がvalueの単一値アノテーションはキー名を省略可能 | |
public String getHoge() { | |
return hoge; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment