diff options
author | Joseph Evans <evonsdesigns@gmail.com> | 2018-02-06 13:09:17 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-06 13:09:17 -0600 |
commit | a4966ff80be8a1535fedf7313231161c3fdf46c1 (patch) | |
tree | 7e378181c91ab13aa0ed5d53ab7f7333057fc12c | |
parent | d509342092ce1bd7755066b041dee2fe0f25bd23 (diff) | |
download | javapoet-a4966ff80be8a1535fedf7313231161c3fdf46c1.tar.gz |
Correct usage of toString()
Should have return type of `String`, not `void`.
-rw-r--r-- | README.md | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -634,6 +634,7 @@ TypeSpec helloWorld = TypeSpec.enumBuilder("Roshambo") .addAnnotation(Override.class) .addModifiers(Modifier.PUBLIC) .addStatement("return $S", "avalanche!") + .returns(String.class) .build()) .build()) .addEnumConstant("SCISSORS", TypeSpec.anonymousClassBuilder("$S", "peace") @@ -654,7 +655,7 @@ Which generates this: public enum Roshambo { ROCK("fist") { @Override - public void toString() { + public String toString() { return "avalanche!"; } }, |