Page 1 of 2 12 LastLast
Results 1 to 20 of 27
  1. #1
    Join Date
    Aug 2015
    Posts
    18
    Rep Power
    0

    Default Please help I can't find this code

    Is there a command code that reads the user input and searches in the input for a given keyword for example:

    String HowPersonFeels
    System.out.println("How are you feeling?");
    HowPersonFeels = input.next();

    if (HowPersonFeels.Has("sad")){ // HowPersonFeels.Has is just an example it is not the real code
    System.out.println("I hope you will feel better");
    }

    else if (HowPersonFeels.has("happy")){
    System.out.println("Lucky you I cannot feel emotion");
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: Please help I can't find this code

    The String Javadoc is here.

    Have a look through and see if you can find a method that looks like it might tell you if a particular String contains another String, or set of characters.

    ...there's a hint there...
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Join Date
    Aug 2015
    Posts
    18
    Rep Power
    0

    Default Re: Please help I can't find this code

    Funny thing I was looking through that when I read your comment

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Please help I can't find this code

    Quote Originally Posted by JulesTheGodOfMC View Post
    Funny thing I was looking through that when I read your comment
    In other words you posted first and then start to do proper research second. You should turn that around.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    Join Date
    Aug 2015
    Posts
    18
    Rep Power
    0

    Default Re: Please help I can't find this code

    No I did some research and then just instead of just standing around and waiting for someone to help continue researching

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Please help I can't find this code

    So if the next time you are just a tiny bit more patient with your research, you don't actually need the help.

    not trying to be a douche here, people who give up too hastily trying to work things out on their own tend to be the ones that keep hitting a wall.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    Join Date
    Aug 2015
    Posts
    18
    Rep Power
    0

    Default Re: Please help I can't find this code

    Yea 2h 30 min of research is not enough I agree...

  8. #8
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Please help I can't find this code

    I cannot believe that you did 2 and a half hours of research and did not find the javadoc in that time, especially when you previously describe that as "some research", and now all of a sudden it has become a great deal of research.

    Don't worry, that's as much as you'll hear from me. Have fun.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: Please help I can't find this code

    Quote Originally Posted by JulesTheGodOfMC View Post
    Funny thing I was looking through that when I read your comment
    The API should be your first port of call when looking for a method you think ought to be available on a class.
    I use it all the time, largely because I can never remember method names or exactly what they expect as parameters...:)
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  10. #10
    Join Date
    Aug 2015
    Posts
    18
    Rep Power
    0

    Default Re: Please help I can't find this code

    Tolls I do not fully understand

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: Please help I can't find this code

    The API, which is where that page on the String class lives.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  12. #12
    Join Date
    Aug 2015
    Posts
    18
    Rep Power
    0

    Default Re: Please help I can't find this code

    What should I search because im not really sure and the String class means everything associated with it right?

  13. #13
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: Please help I can't find this code

    The object you want to interact with is a String. That's what the HowPersonFeels refers to.

    So I would normally look at the API for that class to find a method that does what I need. There's no guarantee, especially if it's something slightly unusual, but it should be the first thing you look for.

    "Does this class already do what I need so I don't have to reinvent the wheel"
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  14. #14
    Join Date
    Aug 2015
    Posts
    18
    Rep Power
    0

    Default Re: Please help I can't find this code

    What do you mean "reinvent the wheel" invent a code which does what I need it to?

  15. #15
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: Please help I can't find this code

    "Reinvent the wheel" == Create code that already exists in the API.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  16. #16
    Join Date
    Aug 2015
    Posts
    18
    Rep Power
    0

    Default Re: Please help I can't find this code

    does the thing I want exist in the API and how do you

  17. #17
    Join Date
    Aug 2015
    Posts
    18
    Rep Power
    0

    Default Re: Please help I can't find this code

    create it?

  18. #18
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: Please help I can't find this code

    You just said you looked at the String API link I gave waaaaay up the top of this thread.

    You must have found the method that finds if a String contains another String...
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  19. #19
    Join Date
    Aug 2015
    Posts
    18
    Rep Power
    0

    Default Re: Please help I can't find this code

    not yet

  20. #20
    Join Date
    Aug 2015
    Posts
    18
    Rep Power
    0

    Default Re: Please help I can't find this code

    but this is interesting too im still looking at it i was merely in the begining and I had to pause for my own reasons. its probably there but now im also interested in this

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 10
    Last Post: 08-17-2014, 11:03 PM
  2. Problems with code/cannot find symbol
    By VIhuri in forum New To Java
    Replies: 4
    Last Post: 11-12-2012, 05:52 PM
  3. Find the Error in Class Code
    By Humphrey Bogart in forum New To Java
    Replies: 3
    Last Post: 03-30-2011, 04:43 PM
  4. Help with my code to find MinOfAll numbers
    By May.ver.rick in forum New To Java
    Replies: 9
    Last Post: 04-20-2010, 04:46 AM
  5. how to find if the code contains deprecated API?
    By Pooja Deshpande in forum Advanced Java
    Replies: 3
    Last Post: 05-29-2008, 09:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •