Naming: Why should named constants be all uppercase in C++/Java?

前端 未结 15 1760
情歌与酒
情歌与酒 2020-12-15 16:13

I know, that for C++ and Java it is a well established naming convention, that constants should be written all uppercase, with underscores to separate words. Like this (Java

15条回答
  •  北海茫月
    2020-12-15 16:22

    Coding conversions are to improve readability. You don't have to use letters. Java allows $ symbol for example.

    public final static Color $$ = COLOR.WHITE;
    public final static Color $_ = COLOR.BLACK;
    

    You could number your variables too, but that doesn't mean its a good idea. ;)

提交回复
热议问题