Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Passwords not matching read using Console

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there ,
I have created a program that stores and authenticates a user using a file .
Here is the code :


The passwords don't match even if I enter same passwords . How to solve this problem ?
Whenever a new user enters , the data overwrites the previous contents of the file , how to append ?
Can I use regex to compare here ? Any ideas will be appreciated ..thanks
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You twice made the assumption that a char[] is the same thing as a String. Its not:

In your store method you have the equivalent of:

You expect it to do create "my name:abc" but it won't, because char[] is not a String.

Second, in your verify method you have the equivalent of:

You expect that this would return true. But since a char[] is not the same as a String and so could never be equal.
 
Raman Ghai
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You twice made the assumption that a char[] is the same thing as a String. Its not:


Just to confirm

Output : false
Well , I need to find some other way out. Btw thanks for replying
 
Marshal
Posts: 27375
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, there's a String constructor which accepts a char array, isn't there?
 
Raman Ghai
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Well, there's a String constructor which accepts a char array, isn't there?


Yes, there is


//Calls

thanks
 
Just let me do the talking. Ahem ... so ... you see ... we have this tiny ad...
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic