开发者

Get number in properties as String (java.util.Properties, Android)

I have a property

text=000.01

but using java.util.Properties's method

getProperty("text");

returns "0.01" (must be "000.01")

P.S. Methods:

get("text").toString();

returns "0.01" too.

P.S.S Take into account this is Android code.


some time later

The Properties#getProperty method works fine. The problem was in my incorrect definition of column in SQLite db. I declared column as integer which worked fine with String data. So when I stored "some string" I din't get any problem and forgot about integer type.

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 ha开发者_StackOverflow中文版rdware 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() method always return String that doesn't know 000.01 = 0.01 in maths context. So this shouldn't happen.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜