String.startsWith, method behaves like the method String.equals

Hello

I work through the assignment of the Java Servlets and JSP, and told me to use a simple iterator method and startsWith. This bit is not part of the assignment as they write it for you, but it does not work for me.

Grateful for any help, I'm not cheat my assignment because it comes to Servlets and JSP, and I'm not marked on this part.

Here is my results using System.out during an iteration through my loop.

Green home starts with the Green House
the Pink House does not start with the Green House
the Blue House does not start with the Green House
the Pink House is bigger that the Pink House does not start with the Green House
the Green House is bigger that the Pink House does not start with the Green House
the Green House is bigger that the Green House does not start with the Green House
the Green House is bigger that the Red House does not start with the Green House
the Blue House is bigger that the Pink House does not start with the Green House


My table list is built like this: -.

searchPrompts = new ArrayList < String > ();
searchPrompts.add ("the Green House");
searchPrompts.add ("the Blue House");
searchPrompts.add ('pink house');
etc.


and my loop is less and does not compile if I throw the (String): -.

int countMatches = 0;
for (Iterator it = searchPrompts.iterator (); it.hasNext () & & countMatches < = 5 ;))
{
String aPrompt = (String) it.next ();
If (searchString.StartsWith (aPrompt))
{
System.out.println (aPrompt + "begins by" + searchString);
matchingPrompts.add (aPrompt);
countMatches ++;
}
on the other
{
System.out.println (aPrompt + "does not begin by" + searchString);
}
}

Your code says:

If one starts with B, then print "B starts with a.

Until your prints claims is put trial is not actually what is being tested.

Tags: Java

Similar Questions

  • How can I make Android V35 behave like the V24?

    I use FF on Android, I've been holding until the update since 24 V for all newer versions will not auto play mp3 for download without interaction. I use this to play on Google voice email messages. How can I make 35 V behave like a 24 V?

    Thanks Roland, I guess all I can ask is that you can do occur in future releases and maybe make an adjustment if it is a problem for other users to access this feature.

    Thanks Bob

  • Subvi behaves like the dialog box

    Hello LV'ers.

    I have a problem in my program of LV: 'I need my Subvi to behave like a dialog box.

    Design: if I call this Subvi (through the server VI - FPopen of the property node), my mainVI should NOT be controlled until the end of the Subvi. I think it's the same based on the dialog box, once the dialog box appears, we need to deal with first before you can make the controls of our main VI.

    my current status: I have two while loops, running in parallel: 1st loop for tracking data, 2nd loop of the menu setting. the Subvi that opens has been in the 2nd loop - it appears when I pushed the button (event structure/VIserver). now, once I called this Subvi, I can still click and control my mainVI that should not happen!

    I think it's quite possible, I don't know how. Anyone who knew this feature?

    Kind regards

    Properties of Sub - vi, the appearance of windows, click on Dialig.

    /Y

  • Data entry of DataGrid - get behave like tab

    I have a DataGrid with editable lines and some modified lines. What I need is for data entry occurs through the editable columns before moving down a line. Just like the DataGrid contains when the tab button is used.

    Basically I want the Enter key to behave like the Tab key.

    How can I go to achieve this?

    Add a listener to high priority for KEY_DOWN.  Call stopImmediatePropagation.

    Display a FocusEvent.KEY_FOCUS_CHANGE event instead.

  • How Windows Explorer can be configured to browse the folder hierarchy instead of behaving like a browser?

    I work with files in a folder tree.  I want to browse this folder hierarchy, just as I did in the original copy of Windows Explorer in Windows XP.  I want to use the arrow keys to navigate up and down, and when I'm in a folder and click the previous button, I want it to go up one level in the folder hierarchy, just like he used to.

    Now, when I hit the 'back' button, Windows Explorer behaves as a browserand goes to the last folder that I have read.

    It's so frustrating!  She interrupts my thought process and the movement of my work.  If I wanted to use a browser, I use Internet Explorer.

    How Windows Explorer can be configured to browse the folder hierarchy instead of behaving like a browser?  Remember the "unwebified" of Windows XP Windows Explorer version?  This is what I want so I can get back to work effectively.

    Windows Explorer 7 does not have the up button like XP, however, in the address bar you can select the folder in the hierarchy (sometimes called the trail of bread crumbs) to return.

    Windows 8 added the arrow pointing upwards.

  • Select the list that behave like trees

    Hi all

    I use apex 4.2.5.

    I want to create a tree like the list item, which shows the child records under main folders.

    for example, in the emp table, employees of managers. so I want to create a list which show and then employees managers under each manager way as only one employee may be selectable, managers should not be selectable.

    How to do this?

    Thank you

    Maahjoor,

    Consult the Group by list select plugin that helps you choose the child entries

    I hope this helps.

  • How can we ADFFaceMessage behave like Modal = true?

    JDEV 11.1.1.7

    We add ADFFacesMessage in backing bean that is displayed as a pop-up, but the user is able to do the operation on the Parent screen.

    How can we make the FaceMessage behave like pop-up windows with the dialogue with the attribute set as modal = True. ?

    Kind regards

    CQuest

    This doesn't seem to be possible.

    See Do modal - FacesMessage JDeveloper and ADF or how shoe as modal FacesMessage - JDeveloper and ADF or https://adfnbpel.wordpress.com/2013/03/23/display-faces-message-on-top-of-adf-popup/

  • All my brushes behave like gum... instead of color, they disappear. What can I do?  Thank you.

    Hello world
    All my brushes behave like some gum... so instead of add colors, they erase what's there. I tried for 3 hours to figure that out. I have something I have to finish it today.  Help, please.

    Thank you.

    You have the tool selected history. Select the normal brush.

  • Mobile Web site that behave like an application.

    I created a mobile Web site Muse adobe and wish that it behaves like an application added to the home screen. If full fullscreen without the features in safari (iOS). Does anyone have solutions (code) for this?

    The ITI is not possible to create a complete iOS to a website app. Requiring a software development or some kind of conversion tool. You will still see the browser frame, but it will decrease when you move to the bottom of the page, as long as you do not use the scroll effects.

  • How to insert a page in a section, but NOT like the last page?

    How to insert a page in a section, but NOT like the last page?

    and how to integrate fonts in a pdf export?

    How does choose a 5.5 x 8.5 book format?

    Adding pages to get to the end.  You can, however, keep typing to the point you need to add a page. Once the page seems to make corrections.

  • My husband doesn't like the itunes account is under my name.  I have a way that he can have his own name and sign on with her and still exist on the family account?

    My husband doesn't like the itunes account is under my name.  I have a way that he can have his own name and sign on with her and still exist on the family account?  Also, have we HAVE two-step verification?   It's a real pain.

    Yes it can have its own ID and share your content via the family sharing, he needs to sign out of your ID and to create his own, then one of you needs to invite another family sharing.

    You don't need to use 2 verification step, if you want you can disable to my Apple ID

  • When I click on the + to open a new window I don't like the images that arise. I tried to change that in all: config; Browser.newtab.URL, but it will not

    When I click on the + to open a new window I don't like the images that arise. I tried several times to change that through words: config; Browser.newtab.URL. I put in the site I want and it won't change. I tried to put in: blank and it don't work. I'm obviously something wrong - can you help please?

    Thank you

    If Firefox is ignorant preference browser.newtab.url, the usual culprit is an extension.

    You can open the page in Firefox Add-ons using either:

    • CTRL + SHIFT + a
    • "3-bar" menu button (or tools) > Add-ons
    • in the Windows "Run" dialog box, type or paste
      firefox.exe "about:addons"

    In the left column, click Extensions. Then, in case of doubt, disable (or delete, if possible) not recognized and unwanted extensions. Do not forget that all extensions are optional, none come with Firefox, and you can learn more about them by checking their reviews on the site of the Add - ons.

    Often, a link will appear above at least an extension disabled to restart Firefox. You can complete your work on the tab and click one of the links in the last step.

    Any improvement?

  • How can I return my bookmarks menu features before update Firefox 23.0.1? I don't LIKE no internet now explore my firefox behaves like IE. Gee thanks.

    How to restore the functionality of the favorite shortcut. I DO NOT LIKE internet explorer, it is heavy and slow. How can I change the shortcut to bookmarks to act as a menu again? I don't like the bookmarks and history pop-out... Firefox has been above the bar, now I have 2 copies of internet explore on my computer, one with an icon that looks like a E and the other that resembles my old firefox browser... This is the result of the 23.0.1 update this morning, it was perfect when I went to bed last night... Maybe I should use Chrome?

    delete the localstore.rdf if you experience problems with the toolbar buttons.

    To find this file go to FIrefox = button > help = > Troubleshooting Information = > open profile and localstore.rdf file remove the closure of firefox

  • I don't like the new layout, how can I go back the old traced page?

    I don't like the new layout, how to get back the old layout of the page?

    Looks as if you just use the option to hide the navigation toolbar.

    It will be probably temporarily reappear if you press Alt on the keyboard. You can set to display help (I think that - not in Windows Me)

    • Firefox-> toolbars-> toolbar Navigation
  • Don't like the new pdf.js Viewer. How can I disable it and restore Acrobat Reader as my favorite plugin?

    I don't really like the look-and-feel of the new pdf.js Viewer. On my machine (6 yr old HP running Windows XP with sp 3) it displays more slowly than Acrobat Reader, and I was perfectly happy with the Acrobat Reader plugin. Frankly, I want to disable pdf.js, but have not been able to find a way to do it. It does not appear anywhere that I could find the Add-ons Manager. I don't want to be forced to use a feature that seems to be a detriment to performance, at least for me. Mozilla, please review this!

    You can set the pref pdfjs.disabled true on the topic: config page to disable the build-in the PDF Viewer and use the Adobe Reader software instead.

    See also:

Maybe you are looking for