Looking for a hashMap example

Hi, I need to take the details of employees from the user,as an input, in an Employee class and want to insert it as a value to a hashMap, the hashMap key value being the employee number. I am not able to display the hashMap within the code. Can anyone help to solve this problem. Thankyou in advance.

hi thank you for your guidance. Below is my main class.
public class PersonDetails
public static void main(String[]args)
          int noOfUsers;
          String regNumber=null;
          String lastName;
          String firstName;
          int age;
          Map<String, GetDetails> map=new HashMap<String, GetDetails>();
          GetDetails n=null;
     try
          BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
     System.out.println("The number of people details to be entered:");
          noOfUsers = Integer.parseInt(br.readLine());
          for(int i=0;i<noOfUsers;i++)
               System.out.println("Enter the regester number:");
               regNumber = br.readLine();
               System.out.println("Enter the last name:");
               lastName =br.readLine();
               System.out.println("Enter the first name:");
               firstName = br.readLine();
               System.out.println("Enter the age:");
               age = Integer.parseInt(br.readLine());
               n = new GetDetails(regNumber, lastName, firstName, age);
               for(int j=0; j<noOfUsers; j++)
                    map.put(GetDetails.regNumber,n);
     catch(Exception e)
And here is my GetDetails Class.
public class GetDetails
     String regNumber;
     String lastName;
     String firstName;
     int age;
GetDetails(String regNumber, String lastName, String firstName, int age)
     this.regNumber = regNumber;
     this.lastName =lastName;
     this.firstName = firstName;
     this.age = age;
In the main class, am not able to access the details of the employee in map.put(GetDetails.regNumber,n); Sm have not completed the rest of the program as I was confused whether am going in a right way or not. Can you help me to generate this code? To be specific, I need to accept the details of the employee together in one object so that whenever any particular key is requested , its corresponding full details of that person should be displayed.

Similar Messages

  • Looking for simple search example using SELECT

    Can anyone link me to an example of how to create a basic search page where the search criteria is selected in a drop-down list (<SELECT> in HTML)?
    Here's where I'm coming from so you have a better idea of what I'm trying to do. I've created a search page by creating a method in my App Module java class using setWhereClause(), then dropped my view onto my web page as a read-only table, and finally dropped the method and parameter as a command button and input text field, respectively. This works fine, but I'd like to replace the input text field with a select box so that the users will not have to type in their search criteria. I'd like to populate the drop-down with data from a table, which will then be sent as the argument for the method.
    I can create a ViewObject that contains the data I need, but I'm not sure where to go from there. I don't know how to create the drop-down list or connect the command button to the list. (Ultimately, I'd like to have the search text submitted when the drop-down changes, but I'll settle for pressing the button for now). I've fooled with using the LOV component, but without any luck.
    Step-by-step would be great, but if you can point me to an example, some documentation, etc., that would be great too.
    Thanks,
    Andy

    Excellent - Thanks for the link to the sample code page. I thought I had seen all the tutorials, etc. but for some reason never came across this page. The example you cited looks like it's just what I'm looking for.
    (Edit - For anyone who's interested, here's a step-by-step for creating a databound drop down list:
    http://www.oracle.com/technology/products/jdev/tips/mills/databound_lists.html )
    Andy

  • Looking for Simple JSTL Example

    Hi Everyone,
    I'm looking for an example of a simple Web application that uses "JavaServer Pages Standard Tag Library" (JSTL) -- that doesn't use JDeveloper!
    I have OC4J stand-alone 10.1.3.0.0 on Microsoft Windows XP Professional Version 2002 Service Pack2 with JDK 1.5.0_07
    I created and packaged a J2EE application in a EAR file. The EAR file contents:
    META-INF/application.xml
    frstjstl.warContents of "application.xml"
    <?xml version="1.0"?>
    <application
           xmlns="http://java.sun.com/xml/ns/j2ee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"
           version="1.4">
      <module>
        <web>
          <web-uri>frstjstl.war</web-uri>
          <context-root>frstjstl</context-root>
        </web>
      </module>
    </application>Contents of "frstjstl.war"
    META-INF/MANIFEST.MF
    index.jsp
    WEB-INF/lib/standard.jar
    WEB-INF/web.xmlContents of "web.xml"
    <?xml version="1.0"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
             version="2.4">
      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
      <jsp-config>
        <taglib>
          <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
          <taglib-location>/WEB-INF/lib/standard.jar</taglib-location>
        </taglib>
      </jsp-config>
    </web-app>Contents of "index.jsp"
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <html>
      <head>
        <title>Simplest JSTL</title>
      </head>
      <body>
        &lt;h1>Simplest JSTL</h1>
        <c:forEach var="httpRequestHeaders" items="${headerValues}">
          ${httpRequestHeaders.key} = ${httpRequestHeaders.value}
        </c:forEach>
      </body>
    </html>My JSTL implementation comes from here:
    http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html
    The distribution contains a "standard.jar" file and a "jstl.jar" file (among other things). The "standard.jar" file is included in my WAR (see above) and I have copied the "jstl.jar" file to:
    %J2EE_HOME%\jsp\lib\taglibI launch OC4J from the command prompt like this:
    java -jar oc4j.jarI deploy my EAR using the following command:
    java -jar admin.jar ormi://localhost oc4jadmin xxx -deploy -file frstjstl.ear -deploymentName FirstJSTL -bindWebApp default-web-siteThen I launch my Web browser and enter the following URL:
    http://localhost/frstjstlAnd I get the following error message:
    500 Internal Server Error
    OracleJSP: oracle.jsp.parse.JspParseException: /index.jsp: Line # 8, <c:forEach var="httpRequestHeaders" items="${headerValues}">
    Error: Attribute: items is not a valid attribute nameThanks (for reading),
    Avi.

    Thanks Qiang.
    Yes, when I copy file "index.jsp" to directory "%J2EE_HOME%\default-web-app\testJstl.jsp" it works.
    I use the following URL:
    http://localhost:8888/testJstl.jspAnd this is the output I get:
    [Format modified to be more suitable to post on this forum.]
    Simplest JSTL
    CONNECTION = [Ljava.lang.String;@7348e
    USER-AGENT = [Ljava.lang.String;@10b8d03
    ACCEPT-LANGUAGE = [Ljava.lang.String;@157011e
    ACCEPT-ENCODING = [Ljava.lang.String;@10a8143
    ACCEPT = [Ljava.lang.String;@ac8360 HOST = [Ljava.lang.String;@1e534cb
    [/pre]
    But I guess, since the JSTL related JAR files are part of the default Web application, there is no reason it shouldn't work.
    That's why you said:
    Let us do a sanity test first.So now what?
    (And, by the way, thanks for your help.)
    Cheers,
    Avi.
    Message was edited by:
            Avi Abrami                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Looking for good first example for RSS

    Hello,
    I am looking for a good code example which will guide me how to use RSS at the portal. Can anyone please direct me to such example?

    Hi Roy,
        I am posting a xslt that filters the news by searching for any news that has "Troops" and "Pope" in the title of the news. I can send you the complete par if you email me your address at [email protected] You owe me lunch buddy. :). The following xslt is for http://rss.news.yahoo.com/rss/world feed.
    [code]<?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
    <xsl:template match="/rss/channel">
    <a class="urLnk"><xsl:attribute name="href"><xsl:value-of select="link"/></xsl:attribute><xsl:value-of select="title"/></a>
    <xsl:for-each select="item">
    <xsl:variable name="titlestring"><xsl:value-of select="title"></xsl:value-of></xsl:variable>
    <xsl:variable name="pope">Pope</xsl:variable>
    <xsl:variable name="troops">Troops</xsl:variable>
    <xsl:if test="contains($titlestring,$pope) or contains($titlestring,$troops)">
    <table>
        <tr>
             <td class="urTxtStd">
                  <a class="urLnk"><xsl:attribute name="href"><xsl:value-of select="link"/></xsl:attribute><xsl:value-of select="title"/></a>
             </td>
        </tr>
        <tr>
             <td class="urTxtStd">
                 <xsl:value-of select="description"/>
             </td>
        </tr>
    </table>
    </xsl:if>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>[/code]
    Message was edited by: Prakash  Singh

  • Looking for Analog Out example using DMA and C++; cannot find sample "GenMultVoltUpdates_SWTimed"

    Looking for example for Analog Out to multiple channels using DMA and C++.  Found reference to sample "GenMultVoltUpdates_SWTimed" which I do not have and cannot find.

    Hello Gerry,
    When you install DAQmx, there is an option to install
    support for Measurement Studio.  When you
    select this option, it will install these examples onto your hard drive.  All of the examples can be found at the
    following location: (C:\Documents and Settings\All Users\Documents\National
    Instruments\NI-DAQ\Examples\DotNET2.0\Analog Out\Generate Voltage)
    Respectfully,
    Rob F
    Test Engineer
    Condition Measurements
    National Instruments

  • Looking for WebVPN Configuration Examples

    I am looking for examples of VPN Concentrator configurations that provide access to Citrix and applications on the network. I have our intranet and e-mail access working. Any assistance will be appreciated.
    Lou Kirt

    Lou,
    Version 4.7 of the software for the concentrator has support for Citrix with WebVPN. Here is a link to the release notes that describes setting up the concentrator for support.
    http://www.cisco.com/univercd/cc/td/doc/product/vpn/vpn3000/4_7/47con3k.htm#wp499765
    Steve

  • Looking for NIDAQ Functions/​Examples for 'Analog I/O DMA' and 'Digital I/O DMA'. (I am using 6024,6503 boards and VC++ in my project)

    I am using 6024,6503 boards. I need to implement AnalogInputDMA /AnalogOutputDMA,DigitalInputDMA and DigitalOutputDMA blocks for another software. Why there are no NIDAQ functions used with 'DMA' ?

    Alan;
    The NI-DAQ doesn;t have any functions to specifically access the DMA transfers, because that is done automatically for you. Once you set the data transfer to use the DMA channels, all the rest is handled by the driver.
    Once you set up an Analog input task, and select the data transfer to use the DMA channels, you won't have access to the DMA channels but to the datapoints after the transfer.
    Regarding the digital side of the application, I think that what you are looking for is a pattern input/output type of application, that will use DMAs for data transfer.
    The 6503 doesn't offer that functionality. To accomplish that application, you will need one of the board of the 653x family.
    Hope this helps.
    Filipe A.
    Applications Engineer
    National
    Instruments

  • Looking for lab view example

    My application consists of collecting data from a bank of sensors as pressures and tempratures vary. I would like to run a lab view VI that tests the sensors, varies the environment and keeps track of all results, sorting them into good and bad. Each sensor needs to be tested in different pressures, then the temprature increases and the pressure test begins again. If there is a lab view example that might be able to get me started, I really need to find it. Thanks for any and all help.

    There are a number of examples that ship with LabVIEW and their usefulness will depend on information not specified in your questions - such as what version of LabVIEW you have, what type of DAQ card(s) you have, and if you are using any SCXI hardware. If you open LabVIEW and go to Help >> Find Examples, you can search through a number of different examples.
    For the application it sounds like a good place to start would be with an Acquire to Spreadsheet type of file that reads, graphs, and logs data. From there, depending on what you mean my using the card to vary the environment, you can find other examples of AO and DIO to perform these type of functions. These examples will give you a good starting place as to how a LabVIEW program works and the general flow
    that you will need to follow.
    Also, depending on your other needs, you might considering looking into examples with triggering to enable you to control when your program starts.
    Regards,
    Michael
    Applications Engineer
    National Instruments

  • Looking for Hierarchical hashmap

    For resource handling I need to structure my resources :
    for example
    I want to define for key="name" in context="application1/module2/screen4" its value to "name of the customer"
    If the key is not found int this context I want the "hashmap" to search in "application1/module2" context and then in "application1" context.
    Is there a class somewhere that can do that ?

    The Java platform does not currently provide the ResourceBundle you require. However, you can create a custom bundle without too much trouble.
    Regards,
    John O'Conner

  • Looking for a simple example of the Minimax algorithm in java

    Hey everyone,
    I'm currently working on a Gameboy emulator program as a pet project, and for one of the game's I'd like for the enemy AI to use the Minimax algorithm, but I don't have any experience with it (or recursion in general, for that matter). Could anyone maybe post a simple example of how this algorithm works?

    WTF? I'm sure you can find plenty of examples on google. It's on you to take the time to go through them, study them, and, if you still don't understand something, post a clear, concrete question that indicates what you read and what you didn't understand about it.
    As is, you're essentially treating folks here as your research flunkies and saying, "Give me an example that's better than all the ones already easily available to me. Read my mind to know why I didn't like them."

  • Looking for a simple example of how to query all the accounts

    I'm new to the web service model in oracle crm and have been trying to just get a list of the accounts in the system. I generated a .cs class from the account wsdl and added it to my asp.net project. I'm able to get a handle on the account class but not sure the right syntax to make a call out.. As a fyi - i also have been able to login thru the service and obtain a session id.. so I'm that far..
    Are they any existing code examples on how to query this? This is what I have so far but i throws an exception -
    Account act = new Account();
    act.Url = "https://"+dbcon.serverName+"/Services/Integration;jsessionid="+ sID;
    AccountWS_AccountQueryPage_Input qbe = new AccountWS_AccountQueryPage_Input();
    AccountWS_AccountQueryPage_Output qRet;
    qbe.ListOfAccount = new Account1[1];
    qbe.ListOfAccount[0] = new Account1();
    qbe.PageSize = "20";
    qbe.StartRowNum = "0";
    qbe.ListOfAccount[0].AccountId = "";
    qbe.ListOfAccount[0].Description = "";
    //act.CookieContainer = .... is this line needed?
    qRet = act.AccountQueryPage(qbe);
    return qRet.ToString();
    Thanks in advance for your help - Todd
    Edited by: user11139473 on May 6, 2009 6:33 PM

    Hi,
    I am doing the same thing but I am not sure what is Account1 in your case. Can you show me the implementation of Account1 class?
    Account act = new Account();
    act.Url = "https://"dbcon.serverName"/Services/Integration;jsessionid="+ sID;
    AccountWS_AccountQueryPage_Input qbe = new AccountWS_AccountQueryPage_Input();
    AccountWS_AccountQueryPage_Output qRet;
    qbe.ListOfAccount = new Account1[1]; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< qbe.ListOfAccount = new ListOfAccountQuery();
    qbe.ListOfAccount[0] = new Account1(); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    qbe.PageSize = "20";
    qbe.StartRowNum = "0";
    qbe.ListOfAccount[0].AccountId = ""; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    qbe.ListOfAccount[0].Description = ""; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    //act.CookieContainer = .... is this line needed?
    qRet = act.AccountQueryPage(qbe);
    return qRet.ToString();
    On the right is my line of code. The ListOfAccount member of AccountQueryPage_Input has datatype ListOfAccountQuery. In my case, a NULL is returned after the call.
    Did you code work in the end?
    Thanks

  • Looking for Report Writer Example

    I am building an application that allows the users to select the columns they want to see then select filters based on those columns depending on the datatype. Date ranges, etc. All this is working fine. The next step is to save the report parameters the user has selected and let them name the report for future use. It could be a simple as saving the created querystring or, ideally, save the parameters so the filter page could be re-created in its current state to allow changes.
    Does anyone have any examples of something like this?
    thanks

    I am building an application that allows the users to select the columns they want to see then select filters based on those columns depending on the datatype. Date ranges, etc. All this is working fine. The next step is to save the report parameters the user has selected and let them name the report for future use. It could be a simple as saving the created querystring or, ideally, save the parameters so the filter page could be re-created in its current state to allow changes.
    Does anyone have any examples of something like this?
    thanks

  • Looking for a DnD example that runs in the JNLP sandbox

    Can somebody point be to good short example code that illustrates drag-and-drop into an application that is running in the sandbox.
    The example must work with javaFileListFlavor, i.e., I'd like to drag-and-drop files into the application.

    I was aware of the tutorial. It does not answer my question. None of the examples show DnD of files. I am wondering if it would be possible, since it may violate the security policy of the sandbox. Dnd of the file contents only would be good enough for my purposes, but even that seems to be impossible.

  • Looking for a Struts example

    Hi,
    I have been going through the "Struts in Action" (Husted) book and have hit a brick wall now. The first example was pretty easy but then the last "artimus" example is gone way over my head.
    Does anyone have an intermediate example,
    eg, login - query a DB - Add record - Delete - Download/Upload - logout
    Thanks ... J

    Yes, for me too struts were very hard to learn...I
    tried some books, and the best one i think is
    Professional Jakarta Struts from John Wiley &Sons.
    I learned everything from that book. The rest ofthe
    books and websites were hard and didn't cover allthe
    subjects.Without doubt the worst computing book I've ever
    bought! Riddled with typos and the sample code did
    not compile.
    There must be better books on the subject.

  • Looking for a HashMap-Like, where ....

    Hi!
    Is there somethin in Java like sortable HashMap? Or, to be precise, I need a HashMap - Like where the keys stay in the order they were added.
    Thank you :)
    Christian

    Use LinkedHashMap.

Maybe you are looking for