java - 如何键入字符串内容 :encoded = "Hello"; in java?

标签 java android string

如何在java中输入String content:encoded = "Hello";? Eclipse 一直告诉我 token 语法错误删除这些 token ?

setDescription(String content:encoded) {
    _description = content:encoded;
}

最佳答案

因为content:encoded是语法错误。 Java 中的名称只接受字母数字$ 和“_”。该规则可能允许其他一些字符,但应该差不多。变量也不能以数字开头。

为了清楚起见,请从变量名中删除 :,因为 : 在名称中是非法的,并且在语言中可能具有其他含义。

引自以下文章:

  1. Variable names are case-sensitive. A variable's name can be any legal identifier — an unlimited-length sequence of Unicode letters and digits, beginning with a letter, the dollar sign $, or the underscore character _. The convention, however, is to always begin your variable names with a letter, not $ or _. Additionally, the dollar sign character, by convention, is never used at all. You may find some situations where auto-generated names will contain the dollar sign, but your variable names should always avoid using it. A similar convention exists for the underscore character; while it's technically legal to begin your variable's name with _, this practice is discouraged. White space is not permitted.
  2. Subsequent characters may be letters, digits, dollar signs, or underscore characters.

在这里阅读更多相关信息:http://docs.oracle.com/javase/tutorial/java/nutsandbolts/variables.html

关于java - 如何键入字符串内容 :encoded = "Hello"; in java?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21529392/

相关文章:

如果没有 project.properties 文件,Android JNI 将无法编译

c++ - u8R"delim(SomeTextInHere)delim"在 C++ 中是什么意思?

java - 在 Java 中声明 double - 本地一次或从 ArrayList<Double> 重复声明?

java - 客户端服务器应用程序 - Java 中的最佳方法

java - 理论: Two system integration through web service

java - 如何在不发出单独请求的情况下从 shoutcast 流中分离元数据和轨道

java - 从相机/图库加载时图像位图会旋转 [Android 9]

java - Android 向服务器发出请求

string - 检查一个句子是否在pl/pgsql中的字符串中

arrays - 使用具有定义值的 scanf