Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Convert a string to integer

I want to  convert a string field to Integer variable:
(Integer)globalMap.put("BillCount", Integer.parseInt(Trailer.TotalRecCount)))
I got error:java.lang.NullPointerException:null.
I am sure Trailer.TotalRecCount is a existing field in my tMap and is not an empty string. What is wrong in my code?
Another similar conversion that convert a string to double variable is working good.
((Double)globalMap.put("BillTotall", Double.parseDouble(Trailer.TotalAmount))).   
Please help.
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

The put method only returns a value if there was a previous value in the map with the same key. If you add a complete new value to the globalMap the put method returns null.
You should simplify your code like this:
globalMap.put("BillCount", Integer.parseInt(Trailer.TotalRecCount))

View solution in original post

1 Reply
Anonymous
Not applicable
Author

The put method only returns a value if there was a previous value in the map with the same key. If you add a complete new value to the globalMap the put method returns null.
You should simplify your code like this:
globalMap.put("BillCount", Integer.parseInt(Trailer.TotalRecCount))