Java代碼約定:必須匹配模式”^[a - z][a-zA-Z0-9]*美元” - Java Code Conventions: must match pattern '^[a-z][a-zA-Z0-9]*$' -开发者知识库

Java代碼約定:必須匹配模式”^[a - z][a-zA-Z0-9]*美元” - Java Code Conventions: must match pattern '^[a-z][a-zA-Z0-9]*$' -开发者知识库,第1张

i would like to use the following constant:

我想使用以下常數:

final String ADD = "Add text";

But my CheckStyle tool tells me that 'ADD' does not match the pattern '^[a-z][a-zA-Z0-9]*$'.

但是我的CheckStyle工具告訴我,‘添加’不匹配模式”^[a - z][a-zA-Z0-9]*美元”。

Could anyone please tell me what is wrong with 'ADD'? Means '^[a-z][a-zA-Z0-9]*$' that every name has to start with a low character? Is there no other possibility?

有人能告訴我“ADD”有什么問題嗎?意味着“^[a - z][a-zA-Z0-9]*美元”開始,每個名字都有較低的性格?沒有其他的可能性了嗎?

Thanks for answers.

謝謝你的答案。

2 个解决方案

#1


14  

^[a-z][a-zA-Z0-9]*$

This regex describes something which starts with lowercase and the remainder is composed of uppercase, lowercase, and numbers. (Examples: aVariable, variable, aNewVariable, variable7, aNewVariable7.)

這個regex描述了以小寫開頭的內容,其余部分由大寫、小寫和數字組成。(例子:aVariable, variable, aNewVariable, variable7, aNewVariable7。)

If you want your field to be constant and static, use:

如果你想讓你的領域保持恆定和靜態,使用:

static final String ADD = "Add text";

Otherwise, use:

否則,使用:

final String add = "Add text";

最佳答案:

本文经用户投稿或网站收集转载,如有侵权请联系本站。

发表评论

0条回复