java just curly braces

后端 未结 5 1262
一整个雨季
一整个雨季 2020-12-29 05:21

I was reading a book and there were a few example with programs that has just curly braces

for example

 public static void main(String args[]){
             


        
5条回答
  •  渐次进展
    2020-12-29 06:00

    You can logically separate your code by this in some cases, and in fact there's one use case I apply very often: demo data. E.g., you have some demo data generation class that creates demo data entries and inserts into your database. You place each single item in such a block, and can do copy-paste without changing variable names.

提交回复
热议问题