SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Henry Wong wrote:
Make sure you use the equals() method to compare strings. The "==" is used to compare references, and it is doubtful that the value returned from substring will be the same object as the one created for the string literal.
Henry
Khoder Wassouf wrote:
Henry Wong wrote:
Make sure you use the equals() method to compare strings. The "==" is used to compare references, and it is doubtful that the value returned from substring will be the same object as the one created for the string literal.
Henry
Why do you think that its doubtful that the value returned from substring will be the same object as the one created for the string literal???
Khoder Wassouf wrote:
I did what you said but still same error!
Ankit Garg wrote:If you can, use regular expression to achieve this...
Henry Wong wrote:
Ankit Garg wrote:If you can, use regular expression to achieve this...
Agreed. Implemented it in five minutes...
Henry
Khoder Wassouf wrote:
It doesnt tell me what the error is..............it just compiles and then tells me there's an error on line......
Henry Wong wrote:
Khoder Wassouf wrote:
It doesnt tell me what the error is..............it just compiles and then tells me there's an error on line......
It does tell you what the error is. You just need to know how to read it.
Anyway, just compiled and ran your program. It is an array out of bounds error -- basically, the array that you instantiated is not big enough for how you are using it. This is actually not surprising, since it looks like the array that you are creating are of size zero.
Henry
Henry Wong wrote:
Basically, you created an array of size zero at line 23. The for-loop starting at line 26 does absolutely nothing -- because the condition never succeeds. And then it dies at line 50, because you try to access the first element of the zero element array that you created at line 23.
Henry
Khoder Wassouf wrote:
just tell me where I should start looking at and what I should start trying!
Write your code as if the person who maintains it is a homicidal maniac who knows where you live.
OCPJP6/SCJP6 86%
Out on HF and heard nobody, but didn't call CQ? Nobody heard you either. 73 de N7GH
What a stench! Central nervous system shutting down. Save yourself tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|