• Post Reply Bookmark Topic Watch Topic
  • New Topic

Beginning Spring: Syntax for Map<Integer, Double>?  RSS feed

 
H Paul
Ranch Hand
Posts: 491
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Using Spring, is it possible to creat a Map<Integer, Double>? If so, what is the syntax? Any pointer.
so that I can percentageLookup = springContext.getBean("percentageLookup");


With above config, the key is of type String, String.

percentageLookup.get("100") = 2
percentageLookup.get(100) = null

1M Thanks.
 
N Sahni
Ranch Hand
Posts: 55
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You can try modifying your Map creation in spring as:
 
H Paul
Ranch Hand
Posts: 491
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Suggested code works.
2.

Some where we refer Pricer.DEFAULT_PCT.

Syntax-wsie: How can it be declared in Spring configuration file and refer to it?
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
H Paul wrote:1. Suggested code works.
2.

Some where we refer Pricer.DEFAULT_PCT.

Syntax-wsie: How can it be declared in Spring configuration file and refer to it?


You can use the <util:constant> tag to use a constant value in your configuration.

Mark
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!