Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //package com.example.helloworld;
- //public final class HelloWorld {
- // public static void main(String[] args) {
- // System.out.println("Hello, JavaPoet!");
- // }
- //}
- MethodSpec main = MethodSpec.methodBuilder("main")
- .addModifiers(Modifier.PUBLIC, Modifier.STATIC)
- .returns(void.class)
- .addParameter(String[].class, "args")
- .addStatement("$T.out.println($S)", System.class, "Hello, JavaPoet!")
- .build();
- TypeSpec helloWorld = TypeSpec.classBuilder("HelloWorld")
- .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
- .addMethod(main)
- .build();
- JavaFile javaFile = JavaFile.builder("com.example.helloworld", helloWorld)
- .build();
- javaFile.writeTo(System.out);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement