Finding a matching name in an ArrayList

I am trying t traverse an array list and find a matching name but it is not working....can anyone point me in the right direction?
     for(int i=0;i<temp.size();i++)
                    Employee p=(Employee)temp.get(i);
                    if(p.getLast()==name&&p instanceof HourlyEmploye

use generics (if using Java 5 or greater)
compare strings with the .equals() method, versus with ==
import java.util.ArrayList;
class Employee {
     private String lastName;
     private String firstName;
     public Employee() { }
     public Employee(String lastName, String firstName) {
          this.lastName = lastName;
          this.firstName = firstName;
     public void setLastName(String lastName) {
          this.lastName = lastName;
     public void setFirstName(String firstName) {
          this.firstName = firstName;
     public String getLastName() {
          return lastName;
     public String getFirstName() {
          return firstName;
class ETest {
     private ArrayList<Employee> employees;
     public ETest() {
          employees = new ArrayList<Employee>();
          employees.add(new Employee("Smith", "Bob"));
          employees.add(new Employee("Hermanson", "Herman"));
          for(int i = 0; i < employees.size(); i++)
               System.out.println(employees.get(i).getLastName() + " ... " + employees.get(i).getLastName().toLowerCase().equals("hermanson"));
     public static void main(String[] argv) {
          new ETest();
}

Similar Messages

  • Finding string matches in an arraylist

    Hi,
    I have been bashing my head with this for a while, so any help is much appreciated!
    I bascially have ONE arraylist which contains filenames as strings (e.g. file.txt, file1.xml, file2.doc, file2.xml, file2.txt)
    The arraylist bascially contains a document name with there associated metadata document names. For example file1.doc (document file), file1.xml (metedata file).
    There will be siuations where for example file1.doc may not have an associated file1.xml file with it. And there may be situations where there are 2 documents and only one associated metadata file (e.g. file.doc, file1.txt, file1.xml)
    I basiclaly need to loop arond the arraylist identifying only files names that:
    - have an associated metadatafile (once identified put the document name in an arraylist of matches)
    -this arraylist cannot contain duplicate documents with an associated file name (e.g. file.doc, file1.txt, file1.xml), if this particualr situations occurs I want to put these filenames in an arraylist of errors.
    Please help! thanks in advance

    Hi,
    I have been bashing my head with this for a while, so
    any help is much appreciated!
    I bascially have ONE arraylist which contains
    filenames as strings (e.g. file.txt, file1.xml,
    file2.doc, file2.xml, file2.txt)Ok
    >
    The arraylist bascially contains a document name with
    there associated metadata document names. For example
    file1.doc (document file), file1.xml (metedata
    file).
    When you have different pieces of data that have an association with each other (such as your file name String and associated metadata file) you should consider writing a Class to model that association (with the data elements as members). Not only does this more closely reflect what's really going on, but it can save you work (both thinking and coding) later on.
    There will be siuations where for example file1.doc
    may not have an associated file1.xml file with it.
    And there may be situations where there are 2
    documents and only one associated metadata file (e.g.
    file.doc, file1.txt, file1.xml)
    Looks like this new Class needs a List of file names
    I basiclaly need to loop arond the arraylist
    identifying only files names that:
    - have an associated metadatafile (once identified
    put the document name in an arraylist of matches)You could simply have a "hasMetadata()" method in your new class and call it.
    -this arraylist cannot contain duplicate documents
    with an associated file name (e.g. file.doc,
    file1.txt, file1.xml), By overriding the equals method in your new class you can use the contains method of the List.
    if this particualr situations
    occurs I want to put these filenames in an arraylist
    of errors.
    Please help! thanks in advanceGood Luck
    Lee

  • How can you find out if another VI running on the same computer and how can you find out the name of that VI?

    Suppose that several VIs running simultaneously on the same computer. How can I find out the names of the running VIs, from another VI?
    If the already running VIs are clones of the same basic VI, open and run with the option "Prepare to call and forget", how can I find out the names and index of each clone? 

    I had an application where I spawned (= ran with Start Asynchronous Call) multiple (reentrant) copies of VIs, and would occasionally "lose control" of them.  I needed a way to find all VIs that were running "Top Level" and stop them (so I didn't have to log off from Windows).
    I used the Application Property "All VIs in Memory" to get an array of (wait for it ...) All VIs in Memory.  I took each name, opened a VI reference to it (simply wire the name string in, as the VI is, by definition, "in memory"), looked at its VI Execution State, and if it was Run Top Level, Invoked the FP.Close and Abort VI Methods.  [To prevent the VI that did all this from "committing Suicide", I compared the name string with the current Call Chain, and did nothing if there was a match].
    I think you could adopt this idea to do what you need.
    BS

  • Internal error when person doing people search has matching name as search query

    I'm trying to find a solution for peculiar problem in our SP 2010 people search. We get this error 
    Internal server error exception: System.Threading.ThreadAbortException: Thread was being aborted.
       at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTransform(Boolean bDeferExecuteTransform) 
    when person doing the search has matching name. e.g. I as a person have name: jane doe. If I do people search either using jane or doe, I get internal error. If I search john or any other phrase, people searches return correct result. Has anyone encountered
    similar problem and found a solution for that?

    Hi mummo:
    Perhaps you can refer to the following Web site.
    http://blogs.msdn.com/b/allenwang/archive/2011/04/05/sharepoint-2010-people-search-error-dataformwebpart-prepareandperformtransform.aspx

  • Using the LIKE operator with wildcards to match names

    I am using SQL in ColdFusion 9 to match names in an MS Access 2003 database table.
    The Visitors field of MyTable contains the name "Smith" in six records.
    1. Smith Jones Wilson
    2. Smith, Jones, Wilson
    3. Smith(Jr.), Jones, Wilson
    4. Jones Wilson Smith
    5. Wilson Smith Jones
    6. Smith
    7. Smithson, Jones, Wilson
    8. Jones, Wilson, Arrowsmith
    To find out which records contain the name Smith (but not Smithson or Arrowsmith) I now need to write four "OR" lines:
    WHERE MyField LIKE 'Smith[!a-zA-Z]%'  (finds only the Smiths in records 1, 2 and 3)
             OR MyField LIKE '%[!a-zA-Z]Smith'  (finds only the Smith in record 4)
           OR MyField LIKE '%[!a-zA-Z]Smith[!a-zA-Z]%' (finds only the Smith in record 5)
           OR MyField = 'Smith'   (finds only the Smith in record 6)
    I would like to know how to combine these four lines into one which would find all six records containing Smith.
    Thank you for your help.

    As this is a SQL-specific question, you might be better off asking it on a SQL forum?  Does Access even support regexes?
    For a CF the regex you'd be after "\bsmith\b".  You should read the Access regex reference to see if it supports this.  A CF regular expression is no use to you here as the comparison needs to be done on the DB,  not in CF.
    Adam
    Misread the question.  Revising.

  • Cannot find OSB user name

    A former colleague set up OSB on a server several months ago. Now I am trying to sign in the "file system backup and restore" area, and need the user name and password that was created. This must be a different user name than OSB Admin -- and of course it's not in our documentation for this server.
    Is there a query or config file that might hold the user name? If not, what recourse do I have? Destroying OSB and rebuilding? It was a pain to get working in the first place. (OSB Express / Win2003 / internal DAT72 )
    Thanks ...

    Exception: Cannot find bean under name ...
    Probable Cause: This is usually seen in association with a problematic Struts HTML SELECT custom tag. The Struts html:select tag behaves differently depending whether one or both of the name and property attributes is specified for its encompassed <html:options> tags. If the name attribute is specified, whether or not if the property attribute is specified, then a bean matching the specified name will be expected in some scope (such as page, request, session, or application). If the matching bean is not found in any available scope, the error above will be seen.
    There are two ways to address this. The first approach is to put a bean in one of the scopes so that the html:options might be associated with it. The second approach is to not specify the name attribute and instead use only the property attribute.
    Change your Frombean scope from "Request" to "Session", then it works.
    Thanks,
    Thagelapally

  • Cannot find Bean under name..

    Hello everyone,
    I'm new to struts, please be patient with me!!
    I have a series of JSP pages with forms, when I submit a form, I store the contents to the database & take the user to the next page, if its an update action, I need to populate the forms on load.
    The storing part & populating parts are working fine (using ActionForm) BUT the page transitions are not working. I mean, after storing to the database I send a "success" message & my next page is not getting loaded. I'm geting this error "Cannot find bean under name projectOverviewForm" (2nd form name).
    Here's the code snippet...
    struts-config.xml:
    <form-beans>
    <form-bean name="projectIdentificationForm" type="roi.form.ProjectIdentificationForm"></form-bean>
    <form-bean name="projectOverviewForm" type="roi.form.ProjectOverviewForm"></form-bean>
    </form-beans>
    <global-forwards>
    <forward name="identification" path="toolBg.identification"></forward>
    <forward name="overview" path="toolBg.overview"></forward>
    </global-forwards>
    <action-mappings>
    <action path="/identification" type="roi.action.ProjectIdentificationAction" parameter="method" name="projectIdentificationForm" scope="request" validate="false">
      <forward name="success" path="toolBg.identification"></forward>
      <forward name="nextSuccess" path="toolBg.overview"></forward>
      <forward name="deleteSuccess" path="roi.welcome"></forward>
    </action>
    <action path="/overview" type="roi.action.ProjectOverviewAction" parameter="method" name="projectOverviewForm" scope="request" validate="false">
      <forward name="success" path="toolBg.overview"></forward>
      <forward name="nextSuccess" path="toolBg.scd"></forward>
    </action>
    </action-mappings>On searching on the web, I heard this error mostly occurs due to html:select but I'm not using it in my JSP.
    Please let me know if I need to upload any more code? Any help would be greatly appreciated!
    Thanks & Regards,
    Vidya Shankar

    Exception: Cannot find bean under name ...
    Probable Cause: This is usually seen in association with a problematic Struts HTML SELECT custom tag. The Struts html:select tag behaves differently depending whether one or both of the name and property attributes is specified for its encompassed <html:options> tags. If the name attribute is specified, whether or not if the property attribute is specified, then a bean matching the specified name will be expected in some scope (such as page, request, session, or application). If the matching bean is not found in any available scope, the error above will be seen.
    There are two ways to address this. The first approach is to put a bean in one of the scopes so that the html:options might be associated with it. The second approach is to not specify the name attribute and instead use only the property attribute.
    Change your Frombean scope from "Request" to "Session", then it works.
    Thanks,
    Thagelapally

  • Why can't I find any matches ?

    My first query select PONumber and itemNO from table1 based
    on the document number entered in the form.
    <cfquery name="qryName1" datasource="dbName">
    select
    PONumber,
    rtrim(itemNo) as itemNo
    from table1
    where documentNo = '#form.documentNumber#'
    </cfquery>
    I then take the two fields retrived and match it against this
    table, to get the pGR and netPrice.
    <cfquery name="qryName2" datasource="dbName">
    select pGr, netPrice
    from OpenPO
    where
    (purchDoc = '#qryName1.PONumber#' and Item =
    '#TRIM(qryName1.itemNo)#')
    </cfquery>
    What is happending is that the PONumber matches but the
    itemNo does not match. That is why I rtrim in the sql in the first
    query and trim in the where clause in this query but it still does
    not find a match. Both items are defiend as nvarchar 5 in the sql
    tables. I even used cfoutput to show the len and it is 5, so there
    are no blank spaces, yet it still will not find a match, and I know
    there are matches.
    Any anybody tell me what is wrong and/or what to look for
    ?

    NYG,
    Can you pull out the raw data from the OpenPO table on the
    Item col for the record you want? Perhaps by altering query2:
    <cfquery name="qryName2" datasource="dbName">
    select pGr, netPrice, Item
    from OpenPO
    where purchDoc = '#qryName1.PONumber#'
    </cfquery>
    I realize this might bring back several records but it could
    be helpful to see what the DB has versus what you're comparing.
    In addition, what happens if you adjust the query2 where
    clause to use a like for the itemNo)?
    where (purchDoc = '#qryName1.PONumber#' and Item like
    '%#TRIM(qryName1.itemNo)#')
    Also, more out of curiosity, does anything change if you
    alter query1 to change the name of the alias for ItemNo:
    <cfquery name="qryName1" datasource="dbName">
    select
    PONumber,
    rtrim(itemNo) as itemNum
    from table1
    where documentNo = '#form.documentNumber#'
    </cfquery>
    More curious than anything on that last one!

  • Installing EM12c: Installer can't find database host name....?

    Hello all,
    I'm trying to install EM12c. I'm near the last steps, alll requirements passed.
    I have a fresh install of 11.2.0.3 database on a second host, listening for connections.
    But the EM12c installer keeps error'ing out saying it cannot find the host name for the database server.
    I can ping that same server name (I've quadruple checked to make sure it is right)....I've cut from the installer and pasted into a ssh session both as root and oracle user on the target GRID/EM install server...it pings just fine.
    ON the database server, I've done tnsping..and it shows listener is up, I've entered valid ports and host name.
    ON the target EM server, I've even entered in the /etc/hosts file...the IP and server name....still to no avail.
    Any suggestions out there on what else to check? I have downloaded and using the latest EM12c install media...I downloaded it about 2x weeks ago...so, should be latest patched version.
    Thanks in advance,
    cayenne
    ps. Sorry...both EM and database server are on RHEL5 These are VMWare VMs....

    mnazim wrote:
    Please paste the listener status and paste the value that you have entered at database connection screen.Ok.
    I'm having to edit out the actual server and SID names, but they do match:
    [oracle@servername ~]$ lsnrctl status
    LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 03-MAY-2012 14:45:12
    Copyright (c) 1991, 2011, Oracle. All rights reserved.
    Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
    STATUS of the LISTENER
    Alias LISTENER
    Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
    Start Date 02-MAY-2012 19:05:49
    Uptime 0 days 19 hr. 39 min. 24 sec
    Trace Level off
    Security ON: Local OS Authentication
    SNMP OFF
    Listener Parameter File /u01/app/11.2.0/grid/network/admin/listener.ora
    Listener Log File /u01/app/oracle/diag/tnslsnr/servername/listener/alert/log.xml
    Listening Endpoints Summary...
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=servername.domain.name)(PORT=1521)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
    Services Summary...
    Service "instance.domain.name" has 1 instance(s).
    Instance "instance", status READY, has 1 handler(s) for this service...
    Service "instanceXDB.domain.name" has 1 instance(s).
    Instance "instance", status READY, has 1 handler(s) for this service...
    The command completed successfully
    The connection info on the EM12c Installer screen,
    Database Host Name: servername.domain.name
    Port : 1521
    Service/SID: instance (Note, I've tried this with instance name simple and with FQDN attached, same error)
    SYS Password: *************
    Thank you,
    cayenne

  • How to find the match code ? what is matchcode : MARA-MTART checktable T134

    hi ALL,
    How to find the match code ? what is matchcode for MARA-MTART and the checktable is T134.
    How to use in select-options using match-code?
    Thanks in advance.
    Points will be rewarded

    Hi
    Hi goto SE11 and inside the table u will see search help
    click on Entry Search Help. there u see the name of the search help for each field.
    Use this Search Help H_T134 in parameters
    select-options: s_mtart for mara-mtart matchcode object H_T134.
    Thanks
    Shiva
    Message was edited by:
            Shivakumar Hosaganiger
    Message was edited by:
            Shivakumar Hosaganiger

  • Discoverer Report: How to find Business Area name from Report Name.

    Hi
    I opened a report in Disco Desktop 4 -> Resonsibiolity --> Report Name.
    So I know Report name but don’t know which Business Area it belongs to.
    How to find Business Area Name from Report Name?
    Cheers
    Vijay

    Hi,
    There is no relationship between reports and business areas. Each report can be built from many folders. Each folder can be in many business areas.
    However you can try the following SQL which may give you the result you want for an v5 EUL. You will have to modify for Discoverer 4 EUL:
    select distinct doc_name, obj.obj_name folder_name, bas.ba_name
    from eul_us.eul5_documents doc
    , eul_us.eul5_elem_xrefs xref
    , eul_us.eul5_expressions exp
    , eul_us.eul5_objs obj
    , eul_us.eul5_ba_obj_links bol
    , eul_us.eul5_bas bas
    where xref.ex_from_id = doc.doc_id
    and doc.doc_name = &your_report
    and xref.ex_to_id = exp.exp_id
    and obj.obj_id = exp.it_obj_id
    and bol.bol_obj_id = obj.obj_id
    and bas.ba_id = bol.bol_ba_id
    Rod West

  • How to find out server name in reports9i

    hi all
    how to find out server name in reports9i
    i need the report server name to call a report
    thanks
    Edited by: vikas singhal on Nov 5, 2008 1:02 AM

    You do not need to do anything, if your Report server is on the same machine as the Forms server (which is usually the case) you simply use the url as
    /reports/rwservlet?report=myreport' and the server will automatically use the default report server.
    then you simply use
    web.show_document('/reports/rwservlet?userid=scott/tiger@orcl&report=myreport&desformat=htmlcss&desname=test.html'Tony
    Try it now
    Edited by: Tony Garabedian on Nov 5, 2008 2:00 PM

  • How do I find out the name of an area menu?

    I can see a report with a specific t-code in an area menu, how can i find out the name of the area menu, when i need to edit it in se43?

    Do a where used list for the tcode in SE93. select area menu in the list.
    Regards
    Sridhar

  • How do I find out the name of my wireless chipset/interface?

    I'm doing a install of Arch and I need to setup my WLAN.
    So the wiki says:
    "After finishing the rest of this installation and rebooting, you can connect to the network with wifi-menu interface_name (where interface_name is the interface of your wireless chipset). "
    How do I find out the name of my interface?
    Last edited by psycho_tea_drinker (2013-07-03 12:36:40)

    psycho_tea_drinker wrote:
    hokasch wrote:
    Check your chipset (lspci), see if the corresponding kernel module got loaded. Look for dmesg errors. Another way to check device names (from the wiki):
    $ ls /sys/class/net
    How do I check if the kernal module got loaded?
    lspci | grep net
    > only shows my ethernet controller
    lsusb
    > does not show it ethier
    I forget to mention that it is a USB wifi dongle (Tplink TL-WN722N). And I'm also running within virtualbox - I hope that does not complicate matters?
    Probably. You'll need to make sure that VB guest can see your USB ports. You'll need the VB wiki pages for that though.
    I don't use it, so can't help, sorry.
    Last edited by skanky (2013-07-03 13:12:46)

  • How to find the screen name in a screen?

    Hello experts
    I  am  using loop at screen to make my selection screen dynamic
    please tell me how to find all screen-name of a screen.
    thanks in advance.
    Chitta Ranjan Mahato
    Moderator message: please think about it before asking, you are naming the selection fields yourself in your program, if still in doubt, just debug your "loop at screen"
    Edited by: Thomas Zloch on Nov 9, 2010 12:57 PM

    I am  writing a program where in selection screen there will be two radio button named application server and presentation server when user choose application server screen changes dynamically and the block containg related to appliction server will be displayed in selection screen. to achieve this i have write code like
    at selection-screen output.
    if <radiobutton-name> = 'X'.
    loop at screen.
    {color:green}
    if  screen-name = 'radiobutton-name'.
    {color}
    if scree
    thanks
    chitta ranjan mahato

Maybe you are looking for

  • Yosemite keeps forgetting my window arrangement

    I'm running OS X Yosemite, 10.10.2 on a: MacBook Pro (Retina, 15-inch, Mid 2014) Processor 2.2 GHz Intel Core i7 Memory 16 GB 1600 MHz DDR3 I have an extra monitor plugged into the laptop via a thunderbolt adaptor, and I've set the windows arrangemen

  • RedHat AS4 and Oracle 10R2 upgrade - performance issue

    Hi all, As part of our database upgrade project (from Oracle 10.2.0.1 to 10.2.0.3), we decided to upgrade our OS as well (RedHat AS4 from Update 2 to Update 4, 64-bit). We are in testing phase now and having some serious performance issues. These bel

  • PLD Header hight

    How can I make the Header in PLD bigger. It looks in the design as ist is but the print out

  • PXI-5610 RF Frequency Response adjustment

    Hello, I have noticed that adjustment for 5610 in RF frequency response is taking long time (about 2-3hr) with Cal exec 3.5, and I have tried to get the PXI chassis in a good enviroment and with some extra fans around since the adjustment has the leg

  • RH 8 Crashing randomly and now project cant open

    I was working on my RH8 HTML project, removing some broken links and editing folder names. I changed the 'root' folder name, it was an empty folder but at the top level under the HTML Files, Images, Multimedia etc menus. That went fine, and I continu