![]() |
String compare
Hi All,
This gives me a null pointer exception: :
System.out.println("\nThere are " + polyInstance.signChanges(tempCoefsArray, noCoefs) + " positive real roots in the equation you entered\n"); |
I'm not sure if it is the same with Chars as it is with strings, but I know with strings, you have to do
:
tempCoefsArray[i].charAt(0).equals |
@PhilBon: The OP is correctly comparing chars with the != operator; however you are correct that in most cases Strings should be compared with the equals method.
@paulchwd: It appears one of the elements in the tempCoefsArray is null. If you did not intend this to be the case you should review the code in which the argument is generated. However, if you accept the possibility that one of the elements of tempCoefsArray might be null, you should check for that before comparing each value. Also, the second argument to the signChanges method is unused within the method, and if it represents what its name would indicate (the length of the array) the information it provides is redundant. |
| All times are GMT -5. The time now is 2:26 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC