Results 1 to 2 of 2
Thread: Map interface-doubt
- 03-21-2012, 08:33 PM #1
Map interface-doubt
input
policy1= {N, Y, Y, Y, N, Y, N, NULL, Y,N}
I got the following outputJava Code:Map<String, Integer> m = new HashMap<String, Integer>(); for(j=0;j<=9;j++) { Integer freq = m.get(policy1[j]); m.put(policy1[j], (freq == null) ? 1 : freq + 1); } System.out.println(m.keySet()); System.out.println(m.values()); System.out.println(m.entrySet()); System.out.println(m.size() + " distinct words:"); System.out.println(m);
3 distinct words:
[null, N , Y ]
[1, 4, 5]
[null=1, N =4, Y =5]
3 distinct words:
{null=1, N =4, Y =5}
Further I want to assign
A1=null, A2=N, A3=Y
A1size=1, A2size=3, A3size=6
Highest value=A3
for(j=0;j<=9;j++){
If(policy1[j]==null)
If(A2>A3)
policy1[j]=A2;
else
policy1[j]=A3;
I Don’t know how can I utilize m values.{null=1, N =3, Y =6}
May i know how to assign keyvalues in the variable A1,A2 and A3.
Thanking You,
With Regards,
NandhiniLast edited by nandhinianand; 03-22-2012 at 02:10 AM.
-
Re: Map interface-doubt
Please edit your post above and:
- Clean up your code. If you are asking volunteers to help you in their free time, it's not asking too much for you to present clean well-formatted readable code. Your indentation is very bad, and your code is quite hard to read. Please have your indentation be consistent and make sense, say 3 spaces, and not jumping all over the place.
- If this question is a new question, but an extension of your previous question, please post a link in both threads so that you don't needlessly divide this dialog.
- Please don't post your new text as quoted text (don't have your new text in a question placed in [quote] [/quote] blocks) as it makes it hard to read.
- Don't post code in quote blocks but in code blocks.
- Consider clarifying your question. I'm not sure what you're asking. How to utilize m-values in what way?
Similar Threads
-
Doubt
By karthikeyan_raju in forum Advanced JavaReplies: 11Last Post: 11-05-2009, 04:48 PM -
have doubt
By ras_pari in forum Advanced JavaReplies: 3Last Post: 10-01-2009, 09:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks