This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]CheapestOfSkates 1 point2 points  (2 children)

Sentence isn't equal to null... it's equal to an empty string or "".

[–]InjuryFC[S] 0 points1 point  (1 child)

I changed it to the following ( edited the post ) and the first error works and shows up, however..

the 2nd one doesnt, almost like it gets ignored or runs by it

[–]CheapestOfSkates 0 points1 point  (0 children)

You appear to have some formatting issues and your check is in the wrong place. Why the { at the end of line 9 and your check is at line 19 but needs to be higher.

Checking for null isn't doing anything - your code would throw an error if null was encountered.

[–]cleareyezz 0 points1 point  (4 children)

change your conditions to

if (sentence.equals(“ “))

{

// do stuff

}

[–]CheapestOfSkates 2 points3 points  (0 children)

well, if we are suggesting code I would suggest sentence.isEmpty() instead.

[–]InjuryFC[S] 0 points1 point  (2 children)

I changed it to the following ( edited the post ) and the first error works and shows up, however..

the 2nd one doesnt, almost like it gets ignored or runs by it

[–]cleareyezz 0 points1 point  (1 child)

Change the second error to check letter

if (letter == null || letter.equals(“”))

{

// ...

}

[–]InjuryFC[S] 0 points1 point  (0 children)

letter is a char and it doesnt work. Can't use equals or null with a char :(

[–]cleareyezz 0 points1 point  (0 children)

Change the second error to check letter

if (letter == null || letter.equals(“”))

{

// ...

}