0

I have encountered a problem with String comparison. (yes I'm using .equals) I found that by converting my seemingly identical strings to charArray one has an additional index containing nothing.

Now I took my string apart using substring and getBytes()

string.substring(0,1).getBytes()

which prints [-17, -69, -65] all other substrings from this string for example:

string.substring(1,2).getBytes()

print a single array [100]

2
  • what is your string? Commented Jan 30, 2017 at 11:33
  • my string is a String object (sorry... while writing the code I was getting a bit lazy) Commented Jan 30, 2017 at 11:34

1 Answer 1

1

While writing this question I found the answer and decided to share in case someone encounters a similar problem. My problem could be solved by changing the files encoding.

The file was encoded in UTF-8 (according to notepad++) and I saved it as UTF-8 without BOM which removed the special char read from the file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.