0

Does Java support to declare a method inside the static block?

Java static block

28th Apr 2019, 1:02 PM
Asanka Karunasekara
Asanka Karunasekara - avatar
4 Answers
+ 1
like this ? static{ x=0; }
28th Apr 2019, 1:03 PM
Taste
Taste - avatar
+ 1
i dont think you can, i dont see how we can access the method if its declared inside a static anon block like that. why not using static method instead ? static final String doMethod(){}
28th Apr 2019, 1:17 PM
Taste
Taste - avatar
0
Hi! static{ final String doMethod(){ //Code } }
28th Apr 2019, 1:10 PM
Asanka Karunasekara
Asanka Karunasekara - avatar
0
Thanks Taste , will do like that way.
28th Apr 2019, 1:18 PM
Asanka Karunasekara
Asanka Karunasekara - avatar