Android 编译器:无法解析符号字符串
当我尝试将 strServerIP 添加到 Server 类时,我得到:
无法解析符号字符串
编译器错误。
为什么?
package com.example;
public class Server
{
//public static java.lang.string SERVERIP;
public static android.R.string SERVERIP;
public static java.lang.string strServerIP = "monster.idsoftware.com";
public static string strServerIP = "monster.idsoftware.com";
public static int SERVERPORT = 27950;
public static int PROTOCOL = 68;
}
When I try to add a strServerIP to the class Server, I get a:
Cannot resolve symbol string
compiler error.
Why?
package com.example;
public class Server
{
//public static java.lang.string SERVERIP;
public static android.R.string SERVERIP;
public static java.lang.string strServerIP = "monster.idsoftware.com";
public static string strServerIP = "monster.idsoftware.com";
public static int SERVERPORT = 27950;
public static int PROTOCOL = 68;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用“字符串”而不是“字符串”
Use "String" not "string"
除了 RickNotFred 的回答之外,
android.R.string
不是一种数据类型,您在Server
实现的第一行中使用它。如果您是 Java 新手,我绝对建议您在 Android 之外花几周时间学习 Java。 Android 对 Java 的使用很奇怪,以至于有些人似乎对同时学习两者感到沮丧。此外,有关 Java 的书籍不会考虑 Android,而有关 Android 的书籍几乎假设您已经了解 Java。
In addition to RickNotFred's answer,
android.R.string
is not a data type, and you are using it as such in the first line of yourServer
implementation.If you are new to Java, I definitely recommend spending some weeks learning Java outside of Android. Android's use of Java is just strange enough that some people seem to get frustrated learning both at the same time. Also, books on Java will not have Android in mind, and books on Android pretty much assume you already know Java.