• Post Reply Bookmark Topic Watch Topic
  • New Topic

comparing two dimensional string array  RSS feed

 
ninio Tiago
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys

I want to compere two element of string array by each other! eventually I want to print Yes or No in matrix . SO, I start reading data from file then split them into two parts .



Now I want to compere each cell from token[0] by another array :



if the days are equal then I want print yes in front of the employee name if not then i want to print No


is this gone work with me as I imagine it to be or do I have to take few more steps to get my code going?

***************** Monday Tuesday

***************Alax yes no

***************alxender no no

***************pob yes yes
 
Campbell Ritchie
Marshal
Posts: 56581
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

You will need to close that Scanner in a finally statement, or use try with resources. Otherwise the file might never be closed.
I think you need to go back to pencil and paper and work out how you are going to record those Strings. Also to work out the logic of the printing, which is not clear from your post.
Why are you using arrays? If you are sure you always have Strings like "ninio,Thursday", then it would be better to create a class which encapsulates those Strings and does the comparisons.
 
ninio Tiago
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I using array because I am reading data from text file a "ninio,Thursday"! is there a way that let me read data from file the save each line in some sort of structure to do the calculation?

I am looking for any examples related to my situation as well? I want at lest to understated how the structure work
 
Campbell Ritchie
Marshal
Posts: 56581
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest you create a class which can take a String like "ninio,Thursday" as a constructor argument and create an object of that class. Start with two such objects, maybe "ninio,Thursday" and "Campbell,Friday", and test them.

Then ask again and consider data structures. There are all sorts of different kinds ready‑made, but I don't know which to suggest because I don't know exactly what you are doing with them.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!