Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2011
    Location
    India,Tamil Nadu
    Posts
    32
    Rep Power
    0

    Default Map interface-doubt

    input
    policy1= {N, Y, Y, Y, N, Y, N, NULL, Y,N}
    Java 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);
    I got the following output
    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,
    Nandhini
    Last edited by nandhinianand; 03-22-2012 at 03:10 AM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default 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

  1. Doubt
    By karthikeyan_raju in forum Advanced Java
    Replies: 11
    Last Post: 11-05-2009, 05:48 PM
  2. have doubt
    By ras_pari in forum Advanced Java
    Replies: 3
    Last Post: 10-01-2009, 10:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •