• Post Reply Bookmark Topic Watch Topic
  • New Topic

help in storing and scanning string in java  RSS feed

 
john clement
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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.
 
Tyson Lindner
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • 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.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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!!!
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!