• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

comparing two dimensional string array

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 75724
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 75724
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Could you hold this puppy for a sec? I need to adjust this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic