This week's book giveaway is in the OCP forum.
We're giving away four copies of OCP Java SE 8 Programmer II Exam Study Guide and have Kathy Sierra, Bert Bates, & Elizabeth Robson on-line!
See this thread for details.
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to find whether strings contained in array of strings constitute a similar character or not?  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having an array of strings and i want to find out whether these strings contained in the array contain a similar character or not.
For example i am having following strings in the array of string:

aadafbd
dsfgdfbvc
sdfgyub
fhjgbjhjd

my program should provide following result:
3
because i have 3 characters which are similar in all the strings of the array(f,b,d).
Can anyone provide me any kind of help?

 
Sheriff
Posts: 4745
131
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start with writing out what you want the program to do, step by step, then try changing the steps into code. Post the code and any specific problems you have.
 
lowercase baba
Bartender
Posts: 12613
50
Chrome Java Linux
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Utsav Harsh wrote:For example i am having following strings in the array of string:

aadafbd
dsfgdfbvc
sdfgyub
fhjgbjhjd

my program should provide following result:
3
because i have 3 characters which are similar in all the strings of the array(f,b,d).


An example is great for illustrative purposes, but it isn't a spec.

Your spec should spell out what to do in all cases and be completely unambiguous. It should include and and all end- and corner-cases you can think of. Is the number of strings always going to be four? Can you have an empty string? etc.

Part of the reason I'm pushing you to write a better spec is that it will make you think about the problem in more detail, and thus make writing the actual code easier.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!