java - 获取属性中的数字作为字符串(java.util.Properties,Android)

标签 java android properties

我有特性

text=000.01

但使用java.util.Properties的方法

getProperty("text");

返回“0.01”(必须为“000.01”)

附注方法:

get("text").toString();

也返回“0.01”

P.S.S 考虑到这是 Android 代码。

<小时/>

一段时间后

Properties#getProperty 方法工作正常。问题在于我对 SQLite 数据库中的列的定义不正确。我将列声明为整数,它可以很好地处理字符串数据。因此,当我存储“某个字符串”时,我没有遇到任何问题,并且忘记了整数类型。

One of the biggest differences between hobbyists and professional programmers is the difference that grows out of moving from superstition into understanding. The word “superstition” in this context doesn’t refer to a program that gives you the creeps or generates extra errors when the moon is full. It means substituting feelings about the code for understanding. If you often find yourself suspecting that the compiler or the hardware made an error, you’re still in the realm of superstition. Only about 5 percent of all errors are hardware, compiler, or operating-system errors (Ostrand and Weyuker 1984). Programmers who have moved into the realm of understanding always suspect their own work first because they know that they cause 95 percent of errors. Understand the role of each line of code and why it’s needed. Nothing is ever right just because it seems to work. If you don’t know why it works, it probably doesn’t—you just don’t know it yet.
Steve McConnell (Code Complete)

最佳答案

getProperty()方法始终返回在数学上下文中不知道 000.01 = 0.01 的 String。所以这不应该发生。

关于java - 获取属性中的数字作为字符串(java.util.Properties,Android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6747519/

相关文章:

java - BufferedReader.readLine() 方法阻塞替代方案

java - 制作时间字符串

java - 从图像的字节中检索创建日期

android - Eclipse 中的 INSTALL_PARSE_FAILED_NO_CERTIFICATES 错误

java - 如何以编程方式导入本地 JSON 文件?

java - HashMap ,无序键

不带 IAdaptable 的 Eclipse 属性 View

java - 多线程服务器转换为 SSL 后,回显消息时出现问题

android 4.4 ionic 硬件按钮返回关闭键盘

c# - 在 C# 中自动实例化 Automatic 属性的字段