HashMap h = new HashMap();

hi,
I get:" cannot resolve symbol", with jdk1.3.1_02
Any idea why?
Thank you
Pierre

Did you import the java.util.HashMap ?

Similar Messages

  • Display values on new window from backing bean HashMap

    Hi,
    I need to open a new window when user clicks on some link from the current page. New window will display few values which are set once the link is clicked.
    I have created a bounded task flow with a jspx page added into the task flow. This jspx page contains a jsff page. While clicking on the link, I have called backing bean method which will create and set a HashMap containing key-value set which is used to display on new window.
    New window is created by javascript. And I am not able to get HashMap values which are set by bakingbean method.
    Is there anyway to solve this?
    Code:-
    Backing Bean method to open new window
    private void launchWindow () {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    // Taskflow parameters map
    Map <String, Object> params = new HashMap <String, Object> ();
    // Get taskflow URL to be opened in new window.
    String taskflowURL = ControllerContext.getInstance ().getTaskFlowURL (false, new TaskFlowId (
    AppsConstants.DESCRIPTION_TASKFLOW_DOCUMENT,
    AppsConstants.DESCRIPTION_TASKFLOW_ID), params);
    taskflowURL = taskflowURL.replaceAll("%2F", "/");
    ExtendedRenderKitService erks = Service.getRenderKitService (FacesContext.getCurrentInstance (), ExtendedRenderKitService.class);
    String jsScriptWindowOpne = "window.open(\"" + taskflowURL + "\", \"" + resourceBundleMapper.getString (AppsConstants.LBL_NOTI_DESC_NEW_WINDOW_TITLE) + "\");";
    try {
    erks.addScript (FacesContext.getCurrentInstance(), jsScriptWindowOpne);
    } catch (Exception e) {
    logger.log (Level.SEVERE, "Exception while adding javascript to open a new window in ExtendedRenderKitService object. " + e);
    New window jsff page
    <af:outputText value="#{backingBeanScope.notification.notificationDescriptionMap}" />
    Output
    I want to get values from this HashMap, to test the size/content of this Map, I have printed this Map.

    Hi,
    Yes its possible..
    A simple google search gave me this Result.
    Betw:
    you can also open taskflow as popup in your page(inline popup) instead of opening the taskflow in other browser window.
    53-taskflow-in-popup-169196.pdf
    Regards,
    Santosh.
    Edited by: Santosh Vaza on May 11, 2011 2:11 PM

  • New HashMap K,V ().put("A", "B") doesn't work

    I try to replace old methods that use Properties parameter with new methods using a Map<K,V> parameter instead. My problems are the old methods that I change to @deprecated and reimplement to use the new Map<K,V> data but convert them from input Properties. But code like this:
    Map<K,V> map = new HashMap<K,V>();
    map.put("A", "B");doesn't compile: The method put(K, V) in the type Map<K,V> is not applicable for the arguments (String, String).
    How can I resolve this?

    I'm surprised the first line is even compiling - unless you happen to have types named K and V in your code somewhere?
    K and V are the names of parameters. In this case, type parameters. They need to be replaced with actual types. Just like the named parameters to methods need to be replaced with actual values.
    Try:
    Map<String, String> map = new HashMap<String, String>();
    map.put("A", "B");

  • Map map = new HashMap(); -why doesnt this work in jdk 1.8.1

    Hi there,
    I'm trying to use a hashmap like this below:
    Map map = new HashMap();
    map.put("Carrots", new Integer(12));
    map.put("Potatoes", new Integer(30));
    map.put("Onions", new Integer(15));
    map.put("Apples", new Integer(40));
    map.put("Cherries", new Integer(300));
    the HashMap() does not exist in my API for some reason.
    Can anyone tell me why this may be?
    i'm using the hashmap with a stringtokenizer to search a text file line by line and increment how many times each keyword occurs.Sound efficient way of doing it?
    cheers,

    do you mean jdk 1.1.8?
    Map and the other Collections API were added in JDK 1.2. for JDK < 1.2, use Hashtable instead.

  • This line give me error Map fillParams = new HashMap(); for calling ireport

    hi master
    sir i flow this link step by step
    http://developers.sun.com/jscreator/learning/tutorials/2/reports.html
    when i us this step
    Double-click the View Report button to display the Java source for the viewReportBtn_action method.
    Add the following code shown in bold to the body of the viewReportBtn_action method.
    Code Sample 5: viewReportBtn_action Method
    public String viewReportBtn_action() {
    // Free up the rowset resources
    tripDataProvider.close();
    then this line give me error
    Map fillParams = new HashMap();
    in out put windows give me this error
    C:\Documents and Settings\Administrator\My Documents\Creator\Projects\TravelReport\src\travelreport\Page1.java:383: cannot find symbol
    symbol : class Map
    location: class travelreport.Page1
    Map fillParams = new HashMap();
    please give me error how solve this error
    thank's
    aamir

    Complete step 17 (2 steps after you paste the code)
    17. Right-click in the source and choose Fix Imports from the pop-up menu.
    I suggest that you complete the following 2 tutorials before you try to do the advanced ones.
    http://developers.sun.com/jscreator/learning/tutorials/2/jscintro.html
    http://developers.sun.com/jscreator/learning/tutorials/2/helloweb.html

  • Difference between Map h = new HashMap() and HashMap h1 = new HashMap()

    Hi,
    I am new to Java.I am just confuse that what are the benifits or difference between these two approaches.
    1. Map map = new HashMap();
    2. HashMap hashMap = new HashMap();
    Please reply as soon as possible.
    Thanks
    Sachin

    Well the difference is that one declares the variable "map" as type "Map"
    The second declares the variable as type "HashMap"
    Why would you want to do this?
    Lets say at some point in the future, you decide you want the Map sorted. ie use a TreeMap instead of a HashMap.
    If you have used "HashMap" everywhere in your code, then you need to change all occurences of it to TreeMap.
    However if you just used "Map", the only dependency on "HashMap" is in this one line of code.
    Which do you think would be easier to change?

  • Map  ? al  = new HashMap ? ();

    arraylist can use
    List<Object> l = new ArrayList<Object>();
    what is Map <?>al = new HashMap<?> ();
    only Map al = new HashMap (); will get Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.

    1, >(Note that it's fine for the key and value to be completely different, unrelated types. But all keys should be of one type and all values should be of one type.)
    I don't get this part , so is ok or not to have different type in one Map , if this is an bad idea
    Map al = new HashMap ();
                        al.put("uid", rs.getInt("PaymentId"));
                        al.put("student_id", rs.getString("UniversityN")); or lets said I have to change then to String , then late , I can't display them out by using
    <c:out value="${stList.student_id}"/> 2, and if , yes, I could use different type in one map , then what I should I replace the ? in my map
    2.List<StudentRecord> studentRecords = new ArrayList<StudentRecord>();
    do you suggest me to use bean ? I try to use map sine I have the situation like [http://forums.sun.com/thread.jspa?threadID=5416282&messageID=10864265#10864265]

  • Hi iam new to java can u tell me  how to convert from hashmap to string

    how to convert from hashmap to string

    Hi,
    This is not pure Java forum. Its more on JDBC and data connectivity to Orcle db from Java API.
    This link may answer your question:
    http://stackoverflow.com/questions/960807/hashmapkey-string-value-arraylist-returns-an-object-instead-of-arraylist
    Twinkle

  • Hashmap problem

    Hi I am getting only last value from hashmap
    codes are below.
    Then I used iterator and getting
    Required string is null or empty
    jsp code
    <bean efine id="a" name="b" property="c"/>
    <bean efine id="e" name="b" property="d"/>
    <%
    java.util.HashMap params = new java.util.HashMap();
    params.put("a",a);
    params.put("b",e);
    session.setAttribute("paramsName", params);
    %>
    action classs code
    Map paramsName = new HashMap();
    paramsName=(HashMap)session.getAttribute("paramsName");
    if (paramsName!=null)
    { Iterator pIter = paramsName.keySet().iterator();
    while(pIter.hasNext()){
    a=(String)pIter.next();}

    How about the following:
    create a class with instance variables of ints to be your counters:
    public int inserts = 0;
    public int updates = 0;
    public int deletes = 0;name the class something... Tally maybe.
    Might be nice to put in methods to increment each like so:
    public void incrementInserts() {
          inserts ++;
    }and so on for the other instance variables.
    then you create one of these and increment its values appropriately, then put it in the hash.
    Code would look something like this:
    Map myMap = new HashMap();
    while ( logfileIterator.hasNext()) {
         String tableName = null;
         boolean lineIsDelete;
         boolean lineIsInsert;
         boolean lineIsUpdate;
          /* put your code here to analyze the line to find out what the table name is,
              whether it's a delete, insert or update, and set above vars accordingly */
          Tally myTally = null;
          if (myMap.containsKey(tableName)) {
                       /* code for second and subsequent times you see this table name*/
                     myTally = (Tally) myMap.get(tableName);
          } else {
                     /* code for first time you see this table name */
                     myTally = new Tally();
                     myMap.put (tableName, myTally);
          if (lineIsDelete) myTally.incrementDeletes();
          /* or if you didn't write that method you could just use [u]myTally.deletes++;[/u] */
          if (lineIsInsert) myTally.incrementInserts();
          if (lineIsUpdate) myTally.incrementUpdates();
    }

  • Missing Value using HashMap and StringTokenizer

    class StringToken
         String Message = "a b Germany";
         HashMap <String,String> map;
    StringTokenizer token;
         public StringToken()
              try
              token = new StringTokenize(Message);
                   map = new HashMap <String,String>();
                   map.put("a","Adelaide");
                   map.put("b","Auckland");
    while (token.hasMoreToken())
                        System.out.print (map.get(pesan.nextToken())+" ");          
              catch(Exception e)
         public static void main(String[] args)
              new StringToken();
    The output like this :
    Adelaide Auckland null
    What i want like this:
    Adelaide Auckland Germany
    The problem is,How to display all value of Message? cos There's no Germany key..i want to make some condition like this, if there's no key in the Hashmap, the value still displayed originally..
    At my code the problem is, if there's no key in hashmap,output wont display the word..
    Thanks Guys...

    Two options:
    1) Instead of
    System.out.print(map.get(pesan.nextToken()));do
    String token = pesan.nextToken();
    String value = map.get(token);
    if (value==null) value = token;
    System.out.print(value);2) Implement a new Map which provides this behavior.
    Cheers

  • Get key values from HashMap

    Hi,
    I'm trying to get the values of the keys in my HashMap into a String array. Here is the code I'm using:
    HashMap row = new HashMap();
    row.put("A","Approved");
    row.put("D","Disapproved");
    row.put("P","Pending Approval");
    row.put("S","For Simulation Only");
    String[] key = new String[row.size()];
    int k=0;
    while (row.keySet().iterator().hasNext()) {
         key[k] = (String)row.keySet().iterator().next();
         k++;
    }What I'm getting:
    key[0] = "A"
    key[1] = "A"
    key[2] = "A"
    key[3] = "A"
    What I want is:
    key[0] = "A"
    key[1] = "D"
    key[2] = "P"
    key[3] = "S"
    Help, please!

    kd, I know that feeling...
    String[] keys = (String[]) row.keySet().toArray(new String[0]);
    In this case toArray will realize that the zero-length array
    is too short and create/return a new array containing objects
    of type String.Strictly speaking, if you don't give any array (toArray()), the array is an Object[], and as kd said, you can't cast to some other type.
    If you give an array of a specific type, you can cast. If that array is too small, the method will create a new array of the correct type. So you might as well pass it an array at least as big, since in this case you can tell how big it should be. This avoids allocating 2 arrays. Obviously the other will is likely to be GC'd, but why create it if not needed. Maybe that's too much of a micro optimization.

  • Get the values of hashmap in another class

    Hi All,
    i already posted this topic yesterday..But i did not get any helpful response..Kindly help me because I am new to java and I need some help regarding hashmap..
    I have a one value object java class which name is HashTestingVO.java
    *******************************************INPUT OF HashTestingVO.java***************************************
    public class HashTestingVO extends PersistentVO implements ILegalWorkFlowACLVO {
    public final static HashMap legalReviewPieceRelatedACLMap = new HashMap();
    legalReviewPieceRelatedACLMap.put("Futhure Path Check","ereview_acl_piece_related_cat1");
    legalReviewPieceRelatedACLMap.put("Send to Legal Review","ereview_acl_piece_related_cat1");
    legalReviewPieceRelatedACLMap.put("Review Precondition","ereview_acl_piece_related_cat1");
    Now i want to get the Hash Map values of this in another class called Testing.java class
    Ex: i need the value like this in Testing.java
    HashTestingVO obj=new HashTestingVO();
    obj.get(Futhure Path Check) -----------> I want to get the value of key1
    Public means you can access it another class..
    But Static means within the class we will use it...

    already posted this topic yesterday..But i did not get any helpful response..Kindly help me because I am new to java and I need some help regarding hashmap..I thing Exposing your dataStructure to any other class is not the right practise.
    You can make the Hashmap object private and nonstatic and provide a getter method in this class to get the value corresponding to any particular key.
    public Object getValue(String key)
      return egalReviewPieceRelatedACLMap.get(key);
    }

  • Retrieving all values from hashmap in order you put them in

    Hi guys,
    I want to retrieve all values from a HashMap in the order I put them in.
    So I can't use the values() method that gives back a collection and iterate over that.
    Do you guys know a good way to do that ?

    You can just do something like this:
    class OrderedMap
        private final Map  m_rep = new HashMap();
        private final List m_keys = new ArrayList();
        public Object get( final Object key )
            return m_rep.get( key );
        public Object put( final Object key, final Object value )
            final Object result = m_rep.put( key, value );
            if ( result != null )
                m_keys.add( key );
            return result;
        public Object remove( final Object key )
            final Object result = m_rep.remove( key );
            if ( result != null )
                m_keys.add( key );
            return result;
        public Iterator keyIterator()
            return m_rep.iterator();
    }Then use it like this:
       for ( Iterator it = map.keyIterator(); it.hasNext(); )
           final Object value = map.get( it.next() );
       }This will be in the order you put them in. However, if you want to do this correctly, you should implement the Map interface and add all the methods. Another thing you can do is download the JDK 1.4 source, learn how they did and do it the same way for 1.2.
    R.

  • Reading HashMap Values From a File

    Hi,
    I haven't done file I/O in quite a while, so I'm a little rusty.
    I have a HashMap<TreePath, Entity> that I need to store persistently. Thus far I have been creating a new HashMap every time a new session starts and populating it with Entity objects that I create from JDBC ResultSets. The TreePath is generated by adding each Entity object to its parent in the JTree. That all works well.
    Now I'm trying to write the HashMap to file using ObjectOutputStream. Basically I want to be able to load the JTree (which does not need to be persistent at this stage), and as I load it I get the TreePath of each TreeNode. If that TreePath is a key in the persistent HashMap, then I want to display the details stored in the corresponding Entity. However, when I try to read the HashMap using an ObjectInputStream, I get a NullPointer.
    I'm not sure whether the problem is in the way I'm trying to write or read the HashMap, or both. I've followed the examples in the API but they don't seem to be doing the job.
    Any suggestions?

    I have isolated the problem.
    HashMap<TreePath, Entity> map = memory.getMap();
    TreePath nodePath = new TreePath(node.getPath()); //where node is a DefaultMutableTreeNode
    System.out.println("1. Desired key is: " + nodePath);
    System.out.println("2. Map contains key: " + map.containsKey(nodePath));
    System.out.println("3. Keys in map: " + map.keySet().toString());When I use a volatile Java object to store the map, an example of the output produced by the following code is:
    1. Desired key is: [DW, Acct]
    2. Map contains key: true
    3. Keys in map: [[DW], [DW, Acct]]
    However, when I use file I/O to make the Java object permanent, an example of the output produced by the following code is:
    1. Desired key is: [DW, Acct]
    2. Map contains key: false
    3. Keys in map: [[DW], [DW, Acct]]
    As far as I can see, line 2 of the I/O output should be true, not false, since line 3 shows that the key is present in the map.
    Am I missing something here, or is the containsKey() method returning the incorrect result? It looks like it is getting its reference to map all wrong.

  • Follow up on XPATH HashMap problem

    Hi,
    I got some great help before on this & am hoping for a little direction. I have a class that calculates the tax from an xml like below:
    <Taxes>
         <Tax TaxCode='code1' Amount='101.00'/>
         <Tax TaxCode='code2' Amount='102.00'/>
         <Tax TaxCode='code3' Amount='103.00'/>
         <Tax TaxCode='code4' Amount='104.00'/>
         <Tax TaxCode='code5' Amount='105.00'/>
    </Taxes>Now, my method below, gets the last 3 values and sums them and applies the code "XT" to it & returns a HashMap that looks like:
    {code1 = 101.00, code = 102. 00, XT = 312.00}.
    public static HashMap getTaxAmounts(String xml) throws Exception {
              HashMap taxes = new HashMap();
              DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
            domFactory.setNamespaceAware(true); // never forget this!
            DocumentBuilder builder = domFactory.newDocumentBuilder();
            Document doc = builder.parse(xml);
            XPathFactory factory = XPathFactory.newInstance();
            XPath xpath = factory.newXPath();
            XPathExpression expr = xpath.compile("//Tax/@TaxCode");
            Object result = expr.evaluate(doc, XPathConstants.NODESET);
            NodeList nodes = (NodeList) result;
            XPathExpression expr1 = xpath.compile("//Tax/@Amount");
            Object result1 = expr1.evaluate(doc, XPathConstants.NODESET);
            NodeList nodes1 = (NodeList) result1;
            for ( int i = 0; i < nodes1.getLength() && (i<2); i++) {
                   taxes.put( nodes.item(i).getNodeValue(), nodes1.item(i).getNodeValue());
                    if( nodes1.getLength() >= 3){
                        float total = 0.00f;
                        for ( int i = 2; i < nodes1.getLength(); i++) {
                                total += Float.parseFloat(nodes1.item(i).getNodeValue());
                        String xt = nodes.item(2).getNodeValue();
                        xt = "XT";
                        taxes.put( xt, total);
           return taxes;     
    /code]
    all that's fine - but now I have to replace the tags in the original XML file so that they look like:<Taxes>
    <Tax TaxCode='code1' Amount='101.00'/>
    <Tax TaxCode='code2' Amount='102.00'/>
    <Tax TaxCode='XT' Amount='312.00'/>
    </Taxes>
    any odeas how I would this???

    Hi, John. I can address one of your questions here.
    However, the picture was slightly cropped at the top and it also had 2 very small borders on the left and right, being printed in landscape.
    A standard digital camera image is proportioned 4:3 (1.33:1). That doesn't match the 6:4 ratio of your paper's dimensions (1.5:1), so unless you opt either to distort the image or crop it, it can't be an exact fit on the paper.
    In the toolbar at the top of iPhoto's Edit view is a pull-down menu above the word "Constrain". You use that menu to specify standard proportions for printing the image. Select "4x6 (Postcard)", and you will see superimposed on the picture a rectangle that has those proportions. What's inside the rectangle looks normal, signifying that it will be printed; what's outside the rectangle is pale and muted, because it will be cropped away when you print. Place your cursor anywhere inside the rectangle, hold the mouse button down and drag, to move the rectangle and change what's included within the print boundary.
    The fact that your printed picture was both cropped and slightly reduced in size (creating the small left and right borders) suggests to me that your printer may not be capable of borderless printing, or that there is a setting for borderless prints you're overlooking somewhere. Since the contents of both the Print and Page Setup dialog boxes are governed by the printer's own driver software, and there's no "borderless" setting anywhere within iPhoto, I think you'll need to review the printer's documentation and/or online help files carefully to see whether you're overlooking something in one of those dialog boxes.

Maybe you are looking for

  • Hp 1315 will not print with 10.6.7

    I cannot find any answers to this strange set of circumstances. I had an old iMac and an hp 1315 all-in-one printer, and everything worked fine. I recently bought a new iMac with OS 10.6.7, and, rather than reinstalling the printer software, I just p

  • In report prog  print pop-up recuried ?

    HI sap experts , i hav created one report program in se38 and on that is hv two screen (1.is normal screen and 2.is module dilog scree) on module screen there is one pushbutton (print) , now  i want whn i vl click on ('print' pushbutton) a pop-up sho

  • Import button to import recorded tv shows missing?

    I record shows with EyeTV on other networked computers in my house.  I can watch the shows, but I can't import them from one of the other Macs.  When I see the shared shows on that computer there is no import button.  On a third Mac I have recorded s

  • NavigationBar in "Maps" app

    hello. I'm a newbie for developping iPhone app. Following is my question: When I push "direction" button which is located at the bottom of "Maps" app, a navigation bar is shown (this bar has 2 textFields). How can I custom navigationBar like this ? p

  • Can I forward IPs without Server.app?

    I want to forward a local IP range (the gateway that a virtual machine uses, Parallels Desktop 8 with host-only networking) to an IP (that a VPN connection of mine uses). By the time I figured out how it should (?) work using the modern tools of rece