Rahul
Rahul

Reputation: 759

How to pass an integer to a parameter through HashMap?

Am new to java and have a query.Please suggest me a solution :

Am doing API level testing and need to pass the request body parameters of a service like below :

Upvotes: 0

Views: 1550

Answers (4)

Alex
Alex

Reputation: 2030

I would suggest you create some kind of a class which will represent your map key/values so it will be easier to work with it for other developers.

Upvotes: 0

utgoer
utgoer

Reputation: 29

You can create a class which holds string and int values. In other words, HaspMap<String,Object>.

Upvotes: 0

vsbehere
vsbehere

Reputation: 666

Convert your integer value in string and then pass it, as your method expect String parameter, you cannot directly pass integer

sell.requestAdd( "Amount",String.valueOf(Your_Integer_Value));

Upvotes: 2

Vitaliy Moskalyuk
Vitaliy Moskalyuk

Reputation: 2583

Java is strongly typed language, so your Map can't store Integer values, as String is defined as both key and value. If you want to store any object - changed map to Map<String, Object>

Upvotes: 0

Related Questions