#simple java question
1 messages · Page 1 of 1 (latest)
Check your (, ) pairings...
And you should really use && there. There's no benefit to the lack of short-circuiting since the second term has no side-effects.
ok
where exactly am i looking
every ( should have a matching ) (and vice versa)
You only have a few places to check. The if statement is the only complex one.
i have it fixed in here
Excellent that's the bracketing fixed. The 'incompatible types' is down to the fact that str.charAt(n) returns a char and "e" is a string. use 'e' instead (a char literal)
in python "" and '' is the same
"e"is a literalString- use.equals(...)to compare strings.'e'is a literalchar- use==to compare chars.
A char is a primitive (a fixed-size type). a String is a reference type allowing Strings of varying lengths. Unlike Python ' is not used to represent strings.
instead of doing == 'e'
can i do this?
because in the future i might have to compare string to string @hollow pilot
The substring is more expensive (creating a new object).
And s.substring(beginIndex) is different from s.substring(beginIndex, endIndex).
declaration: module: java.base, package: java.lang, class: String
shouldnt this work now