简体   繁体   中英

What does a period mean in a variable name?

I saw this in my textbook and was wondering what it was and when to know to use it.

public class TV{
    public static final int MAX.VOLUME = 10; 
    public static final int DEFAULT.CHANNEL = 2;
    public static final int DEFAULT.VOLUME = 4;

In java, there are certain rules when defining a variable name.

A variable name must not ,

  • be a java keyword
  • contain spaces

The first character of a variable name,

  • can be a character ( az|AZ )
  • can be a dollar sign ( $ )
  • can be a underscore ( _ )
  • can not be a number ( 0-9 )

The rest of the name can contain any combination from the following,

  • characters ( az|AZ )
  • dollar signs ( $ )
  • underscores ( _ )
  • numbers ( 0-9 )

All variable names are case-sensitive .


So using a period ( . ) in the middle of an variable name will result in a compile error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM