Quick Java question about private static final keywords for fields

前端 未结 7 1102
梦如初夏
梦如初夏 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 18:56

    It's common in Java to give constants (static final values) an all-uppercase name, so I would write:

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

    See also Code Conventions for the Java Programming Language. (Those are Sun's code conventions that the majority of Java programmers use).

提交回复
热议问题