gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 17:35:33 25 4
gpt4 key购买 nike

我有特性

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 programmersis 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 youthe creeps or generates extra errors when the moon is full. It means substitutingfeelings about the code for understanding. If you often find yourself suspectingthat the compiler or the hardware made an error, you’re still in the realm ofsuperstition. Only about 5 percent of all errors are hardware, compiler, oroperating-system errors (Ostrand and Weyuker 1984). Programmers who havemoved into the realm of understanding always suspect their own work firstbecause they know that they cause 95 percent of errors. Understand the role ofeach line of code and why it’s needed. Nothing is ever right just because it seemsto work. If you don’t know why it works, it probably doesn’t—you just don’tknow it yet.
Steve McConnell (Code Complete)

最佳答案

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

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com