Beginner : Array , String Problems continue.

Hi everybody I am so New in Java or rather not really able to understand Java yet.
I have assignment where I do not know how to think anymore..is probably very easy to those who understand programming but sadly I do not.
Program should do:
1. assign any amount of different strings.
2. user is giving any letter he/she wants and program to find it among given strings.
If searched letter is in any string/ strings , only these strings or string are printed.
3. If in given strings is not searched letter, program has to say it, for ex: there is not letter you search for.
As long as now I have only, strings assigning to array. So there are strings in array but I do not know how to write code where I can find given letter by user.
I just do not know how I should think(anymore at all ;)) here. I am really frustrated and desperate, how to understand this?? Once and for all!!!
I was thinking maybe I should use ArrayList? but how...or Can it be done both ways with Array or with ArrayList?
     public static void main(String[] args) {
          Scanner scan = new Scanner(System.in);
          System.out.print("How many strings ?");
          int antal= scan.nextInt();
          String [] str = new String[antal];
           String string = null;     
          int x;
           scan.nextLine();
             for( x=0;x<str.length;x++){
                  System.out.print("String "+(x+1)+": ");                       
             string= scan.nextLine();
             str[x]= string;
            System.out.print("Write a letter you wish to find :");
            String letter = scan.nextLine();
            char check = letter.charAt(0);
  //somthing in here ....

Thank you very, very much for helping me, this is the first forum where I am getting any answers at all. Thanks guys!
Yes, that is true I have a problem to "see" things in code..I feel " lost in translation " :)...Sometimes I think I understand code and than suddenly code does total different thing than I thought. I have to pass 2 exams of Java basic and bit advance level of Java , all seems very dark now..but I have a hope that I at least pass those exams. Of course it could be fantastic to start understand Java (or any other computer language) and be able to code one day for real. To be honest, I envy you that you can understand Java. When, all code works is so cool and fun! ok, Back to code...
So I read your tips and advices , thanks.
Here is another problem, with help of indexOf(char) I got index for character I searched, fine.
The way i wrote the code I got separate answer for each string(check in code). What I need to have is, separate printed strings where given character is found and nothing else should be printed. Later, I need just one general comment ,only in case if character is NOT found in given strings.
import java.util.*;
public class upp9 {
     public static void main(String[] args) {
          Scanner scan = new Scanner(System.in);
          System.out.print("How many strings ?");
          int antal= scan.nextInt();
          String [] str = new String[antal];
          int x;
           scan.nextLine();
             for( x=0;x<str.length;x++){
                  System.out.print("String "+(x+1)+": ");                       
             str[x]= scan.nextLine();
            System.out.print("Write a letter you wish to find :");
            String letter = scan.nextLine();
            char check = letter.charAt(0);
               for( x=0;x<str.length;x++){
                   str[x].indexOf(check);
                 //     System.out.println("String "+(x+1)+" "+str[x].indexOf(check));
            if((str[x].indexOf(check))>=0)
                 System.out.println("String "+(x+1)+" "+str[x]);
            else
                 System.out.println("Nothing in this string");
  System.out.println();
}is printed.
How many strings ?4
String 1: hello
String 2: other
String 3: alex
String 4: batman
Write a letter you wish to find :a
Nothing in this string
Nothing in this string
String 3 alex
String 4 batmanI should get printed (with other code)...where I don't know how to think here? what code I should use?, what I can what I can not do here...hmmm
//in case found
How many strings ?4
String 1: hello
String 2: other
String 3: alex
String 4: batman
Write a letter you wish to find :a
String 3 alex
String 4 batmanor....
//in case NOT found
How many strings ?4
String 1: hello
String 2: other
String 3: alex
String 4: batman
Write a letter you wish to find : j
Not found

Similar Messages

  • Still Need Help with this String Problem

    basically, i need to create a program where I input 5 words and then the program outputs the number of unique words and the words themselves. for example, if i input the word hello 5 times, then the output is 1 unique word and the word "hello". i have been agonizing over this dumb problem for days, i know how to do it using hashmap, but this is an introductory course and we cannot use more complex java functions, does ANYONE know how to do this just using arrays, strings, for loops, if clauses, etc. really basic java stuff. i want the code to be able to do what the following program does:
    import java.io.*; import java.util.ArrayList;
        public class MoreUnique {
           public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str[] = new String[5]; int uniqueEntries = 0; ArrayList<String> ue = new ArrayList<String>();
             for (int i = 0; i < 5; i++) { System.out.print((i +1) + ": "); str[i] = br.readLine(); }
             for (int j = 0; j < 5; j++) {
                if (!ue.contains(str[j].toLowerCase())) { ue.add(str[j].toLowerCase()); } } uniqueEntries = ue.size(); System.out.print("Number of unique entries: " + uniqueEntries + " { ");
             for (int q = 0; q < ue.size(); q++ ) { System.out.print(ue.get(q) + " "); } System.out.println("}"); } } but i need to find how to do it so all 5 words are put in at once on one line, and without all the advanced java functions that are in here, can anyone help out?

    you have to compare string 0 to strings 1-4, then
    string 1 with strings 2-4, then string 2 with strings
    3 and 4 then string 3 with string 4....right???Here's a way to do it:
    public class MoreUnique {
        public static void main(String[] args) throws IOException {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            final int NUM_WORDS = 5;
            String[] words = new String[NUM_WORDS];
            int uniqueEntries = 0;
            for(int i = 0; i < NUM_WORDS; i++) {
                System.out.print((i+1)+": ");
                String temp = br.readLine();
                if(!contains(temp, words)) {
                    words[uniqueEntries++] = temp;
            System.out.print("Number of unique entries: "+uniqueEntries+" { ");   
            for (int i = 0; i < uniqueEntries; i++ ) {   
                System.out.print(words[i]+" ");
            System.out.println("}");
        private static boolean contains(String word, String[] array) {
                 Your code here: just a simple for-statement to
                 loop through your array and to see if 'word'
                 is in your 'array'.
    }Try to fill in the blanks.
    Good luck.

  • The action could not be completed because of a conflict with the original item. The conflict may have occurred when an existing item was updated on another computer or device. Open the item again and try making your changes. If the problem continues, cont

    I have a user on an iMac 10.6 connected to our domain.  She uses Outlook web access for email on our exchange server.  Last week she received the following message which is randomly preventing her from sending emails.  She claims no attachment was involved in the original email when this all started.  I have not been able to look at her account as she is out of the office but maybe someone else dealt with this issue.  I realize this may not be Mac related but thought I'd give it a try.  She did say it occurred once over two days while working on a PC but it continued over the past weekend.
    If an internal user tries to send a message with infected attachment using Outlook Web Access, it may report the following error message: The action could not be completed because of a conflict with the original item. The conflict may have occurred when an existing item was updated on another computer or device. Open the item again and try making your changes. If the problem continues, contact technical support for your organization.
    This is because F-Secure Anti-Virus for Microsoft Exchange has detected a virus in the attachment. If the user tries to send the message again, the message will be sent but without the attachment. At the same time a blank message with an attachment named "Attachment_information.txt" will remain in the user's Drafts folder. The "Attachment_information.txt" will contain information about the virus detected in the message.

    PS - have found other posts indicating that clips smaller than 2s or sometimes 5s, or "short files" can cause this. Modern style editing often uses short takes ! Good grief I cannot believe Apple. Well I deleted a half a dozen short sections and can export, but now of course the video is a ruined piiece of junk and I need to re-do the whole thing, the sound etc. which is basically taking as much time as the original. And each time I re-do it I risk again this lovely error -50 and again trying to figure out what thing bugs it via trial and error instead of a REASONABLE ERROR MESSAGE POINTING TO THE CLIP IT CAN'T PROCESS. What a mess. I HATE this iMovie application - full of BUGS BUGS BUGS which Apple will not fix obviously, since I had this product for a few years and see just hundreds of hits on Google about this error with disappointed users. Such junk I cannot believe I paid money for it and Apple does not support it with fixes !!!
    If anyone knows of a GOOD reasonably priced video editing program NOT from APPLE I am still looking for suggestions. I want to do more video in future, but obviously NOT with iMovie !!!

  • Error in Remote Web Access - "An unexpected error occurred. Please try again. If the problem continues, contact the person who manages your server."

    I have set up the RWA and I can log in to the web console with my server account. However when I click on any of the shared folders I get this error:
    An unexpected error occurred.  Please try again.  If the problem continues, contact the person who manages your server.
    Does anyone know how to troubleshoot this?
    Regards,
    Maciek

    I had this very same issue with one of our customer's servers that was running Windows Server Essentials. I ended up calling Microsoft about the issue. I hope this helps someone. This originally appeared on my blog: http://techspeeder.com/2014/01/14/remote-web-access-error-an-unexpected-error-occurred/
    Troubleshooting Steps:
    1.  We were getting unexpected errors while accessing shared folders remotely
    2.  The tech found IIS handlers were missing
    3.  She went to IIS > server level ( parent level) and added managed handler mapping  :
    Name: svc-Integrated-4.0
    Request path: *.svc
    Executable: System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    4. Added script mapping:
    Name: svc-ISAPI-4.0_64bit
    Request path: *.svc
    Executable: windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll
    Name: svc-ISAPI-4.0_32bit
    Request path: *.svc
    Executable: windir%\Microsoft.NET\Framework32\v4.0.30319\aspnet_isapi.dll
    5. Ran IISreset.
    6. We were able to access resources in Remote access, then.

  • "Something went wrong. We're having trouble getting to your mailbox right now. Please refresh the page or try again later. If the problem continues, please contact your helpdesk."

    Hi,
    One of my user was unable to receive email from her desktop outlook, browser and her phone. On her outlook, the status of her exchange is disconnected. Then when she tried to access her OWA, this error prompted below "
    "Something went wrong. We're having trouble getting to your mailbox right now. Please refresh the page or try again later. If the problem continues, please contact your helpdesk."
    Her emails started coming in again after about 45minutes later. It happened twice today.
    Anyone have the same symptoms as mind?

    Hi,
    When user is disconnected to Exchange, please test outlook anywhere connectivity for this user.
    Test Outlook Anywhere connectivity
    https://technet.microsoft.com/en-us/library/ee633453(v=exchg.150).aspx
    Please also check if there are any other events in application log.
    Best Regards.
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]
    Lynn-Li
    TechNet Community Support

  • :-( something went wrong Sorry, we can't get that information right now. Please try again later. If the problem continues, contact you

     
      i have ms exchange 2013
    given error web browser
    something went wrong
    Sorry, we can't get that information right now. Please try again later. If the problem continues, contact you

    Hi,
    I would like to verify when this issue occurs, accessing ECP or OWA. If it occurs when accessing OWA, check if all users have this issue. What's more, please take your time to post the screenshot of error information for my further research.
    Here is a kb about "Something went wrong" error for your reference.
    "Something went wrong" error in Outlook Web App may show an incorrect date
    http://support.microsoft.com/kb/2961715
    Hope this can be helpful to you.
    Best regards,
    Amy Wang
    TechNet Community Support

  • Several problems continuous since first installing Firefox. Personal google search settings don't save; remember me options on web sites like Facebook aren't remembered; Youtube and Flixy videos don't play despite removing/reinstalling/upgrading Firefox s

    Several problems continuous since first installing Firefox. Personal google search settings don't save; remember me options on web sites like Facebook aren't remembered; Youtube and Flixy videos don't play despite removing/reinstalling/upgrading Firefox several times; upgraded the latest flash plugin today, but no difference, symptoms are black play box with youtube and white box with Flixy. Disbale AV and antimalware makes no difference either.
    == URL of affected sites ==
    http://

    I have a new problem with secondary web pages opening up without any action on my part other than simply moving the mouse pointer across the screen.

  • My itunes player on my desktop skips when playing songs. I have re-installed but the problem continues. I have Windows7 64 bit.

    My itunes player on my desktop (Windows7 64 bit) skips while playing songs. I have re-installed but the problem continues. Any suggestions?

    I'm expreriencing the same conditions with the same environment.  Windows 8, iTunes-64 11.1.2.32, iTunes Store with a processing bar up to 80 +/- and the POPUP MESSAGE OF "iTunes stopped working. The error ...."
    I UNINSTALLED, iTUNES WITH NO POSITIVE RESULT.  I CHECKED THE FIREWALL AND IS THE SAME DEFINITION AS THE PREVIOUS ITUNES VERSION.
    My iTunes StoreS from my iPhones ARE OK.
    I'm spending a lot of time of research for WINDOW'S iTUNE with no solutions.... 

  • Flex input type for c# string array: string[]

    Quick question, what would the input type for Flex be if the data type on the asp.net c# web service was a string array, string[], it seems to autodetect it as an ArrayCollection but that isnt right, so I would assume array, but i would still like to confirm this.
    thanks
    shaine

    it was actually arraycollection :\
    the actual answer is:
    var _compEmp:ArrayCollection = new ArrayCollection(new Array("Shaine Fisher"));
    thanks

  • String[] array = (String[])vector.toArray();

    Why does the last line cause a ClassCastException?:
    Vector vector = new Vector();
    vector.add("One");
    vector.add("Two");
    vector.add("Three");
    vector.add("Four");
    vector.add("Five");
    String[] array = (String[])vector.toArray();
    Thanks
    [email protected]

    Because toArray () creates an Object array. You need the toArray(Object[]):String[] array = (String[]) vector.toArray (new String[vector.size ()]);Kind regards,
      Levi

  • I have bought and downloaded the new iphoto but it is not installing. I have restarted my computer and the problem continues. Help!

    I have bought and downloaded the new iphoto but it is not installing. I have restarted my computer and the problem continues. Help!

    can you describe exactly what is happening? And give exact error messages
    LN

  • Just download lightroom cc and not open at all. Have desistarei and will install several times and the problem continues ... I need a solution .. thank you  Operating System Windows 7 64bit

    just download lightroom cc and not open at all. Have desistarei and will install several times and the problem continues ... I need a solution .. thank you  Operating System Windows 7 64bit

    Try the following user tip:
    Troubleshooting issues with iTunes for Windows updates

  • HT4623 the server is unreachable. try reconnecting . if the problem continues, verify your settings and contact your administrator.

    the server is unreachable. try reconnecting . if the problem continues, verify your settings and contact your administrator.

    how to set internet..  vodafone

  • Exchange 2013 EAC shows "error Sorry, your request couldn't be completed. Try deleting the cookies from your browser, and then sign in again. If the problem continues, contact your helpdesk."

    Hi,
    My Exchange 2013 Hybrid environment is at CU5 level. Multiple administrators have started experiencing the error message
    "error
    Sorry, your request couldn't be completed. Try deleting the cookies from your browser, and then sign in again. If the problem continues, contact your helpdesk."
    It only started two weeks ago and did not coincide with any infrastructure changes. The message occurs when clicking anything on the EAC GUI and it eventually allows you to perform the operation but only after the message
    pops up a few times.
    I have tried clearing the browser cookies, history, etc. Note that using the Office 365 EAC does not yield the same messages and it only happens in IE (IE 11).
    Thanks.

    Hi,
    From your description, please make sure that the "Require SSL" is checked in IIS Manager -> Sites -> Exchange Back End -> ECP -> SSL Settings.
    What's more, ensure that EAC site is added to the “Compatibility Mode”.
    Hope this can be helpful to you.
    Best regards,
    Amy Wang
    TechNet Community Support

  • I can't update my apps. I touch the "Update All" button; it asks me for my Apple ID password but after I enter it nothing happens. I tried to update apps one by one but same problem continues.

    I can't update my apps. I touch the "Update All" button; it asks me for my Apple password but after I enter it nothing happens. I tried to update apps one by one but same problem continues. Help please

    The app that does not want to update was it originally downlaoded with a different ID?  If so use that ID and hte password you set for it to update the app

Maybe you are looking for

  • Cant login to itunes anymore,  Keep getting error Apple ID does not have permission to access iTunes Connect.

    Cant login to itunes anymore with any of my iphones.  I have 3.  Now I get an error with the following for any phone I try: Apple ID does not have permission to access iTunes Connect. I have 2 separate Apple Id Accounts for each phone, both get the s

  • Itunes default file location - how do i change it?

    Hi, can anyone help. for some reason, itunes defaults to a folder on my works network, and so when off line at home itunes will not work. i need to change the file location so that itunes looks at my local drive and i can use it off line to upload my

  • DVD cleaning

    I've burned about 50 dvd's on this machine and now I'm seeing distortions where the pixels seem to deteriorate at certain spots. Does the unit need cleaning? How do I do that?

  • Capture is just black screen

    just got fce 4. using sony camcorder to capture. capture area says VTR OK, and controls allow play, stop shuttle---thats working fine, but when i CAPTURE NOW, i just get a black screen. saw other posts that suggested setting view>video to canvas. did

  • How to keep HTML code in the applet source (.java) file itself?

    Hi, How to keep HTML code (APPLET tag) in the applet source (.java) file itself? Please give an example? thank you,