• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help in storing and scanning string in java

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am building an app, where I have to store the data eg: "hello ! how are you" in java as a string and then use scanner to get input and check if the entered word is present in the line stored. If it is stored then the entire sentence must be displayed.
eg : if the stored string is "hello how are you"

if the entered string is "how", then the entire sentence "hello how are you" should be displayed.

I am new to java. any help is highly appreciated. thanks in advance.
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use the contains(...) method. If true just output the string. That's the gist of it anyway. If you're searching through multiple strings or strings with multiple sentences you're program will be a lot more complicated.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi John,

We're glad you found your way here. Folks around here are happy to help, but your question, as stated, makes it kind of hard to know where to begin. We have no way to know if you need help installing the JDK, compiling a program for the first time, correcting a typo, or what.

Thing work best if you ask specific, directed, and focused questions, as opposed to broadly stated "i need help".

Can you tell us what you've done so far? if you have some code written, post it here!!! We have a FAQ on How To Ask Questions On JavaRanch which you may want to skim. It is full of advice on what we think works best around here.

Welcome!!!
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic