Quick Java question about private static final keywords for fields

前端 未结 7 1090
梦如初夏
梦如初夏 2020-12-13 18:48

I\'m declaring a field:

private static final String filename = \"filename.txt\";

First, does the order of private static final

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-13 19:02

    1. No. But that is the sequence I usually see used.

    2. It's a reasonable choice, but some would prefer a configuration file, either Properties or another file format (e.g. XML). That way, you can change the filename without recompiling.

提交回复
热议问题