Javadoc for local variables?

前端 未结 6 1328
名媛妹妹
名媛妹妹 2021-01-17 09:33

Short question: Is it possible to create Javadoc for local variables? (I just want an explanation for my local variable when hovering over it in Eclipse) Thanks for any hint

6条回答
  •  甜味超标
    2021-01-17 10:13

    The local variable should be declared a few lines above its usage. Just use regular comments if you need to. But more importantly, keep methods short, choose meaningful names for them, and declare them only when you need them. Most of the time, it's completely unnecessary to comment local variables.

    Prefer

    int numberOfBooks = books.size();
    

    over

    // the number of books
    int n;
    ... // 50 lines of code
    n = books.size();
    

提交回复
热议问题