19 Replies - 829 Views - Last Post: 20 May 2012 - 12:41 PM
#16
Re: New to Programming .. Passing an array of objects into a method?
Posted 19 May 2012 - 11:27 PM
Don't worry
i just had to get rid of the ";" at the end of my if statement
#17
Re: New to Programming .. Passing an array of objects into a method?
Posted 19 May 2012 - 11:36 PM
if (subjectCode == (codes [i].substring (0,3)));
disciplineCodes.add (codes [i].substring (3,6));
The semi-colon at the end of the statement ends the if clause. It's not always returning true, but the next line always executes, because it's not part of the 'if' clause.
Use the equal() method to compare objects:
if ( subjectCode.equals( (codes[i].substring(0,3)) ) );
disciplineCodes.add (codes [i].substring (3,6));
The semi-colon at the end of the statement ends the if clause. It's not always returning true, but the next line always executes, because it's not part of the 'if' clause.
Use the equal() method to compare objects:
if ( subjectCode.equals( (codes[i].substring(0,3)) ) );
#18
Re: New to Programming .. Passing an array of objects into a method?
Posted 19 May 2012 - 11:53 PM
I love this forum
! Thanks heaps!!
#19
Re: New to Programming .. Passing an array of objects into a method?
Posted 20 May 2012 - 01:32 AM
Hey guys,
Thank you for posting this discussion here, I'm also having with this type of problem....but now I've seen you're discussion, I know what to do with my source code
Thank you for posting this discussion here, I'm also having with this type of problem....but now I've seen you're discussion, I know what to do with my source code
#20
Re: New to Programming .. Passing an array of objects into a method?
Posted 20 May 2012 - 12:41 PM
Quote
Use the equal() method to compare objects:
if ( subjectCode.equals( (codes[i].substring(0,3)) ) );
if ( subjectCode.equals( (codes[i].substring(0,3)) ) );
Expanding on this some. With Objects, the == operator compares their memory locations, not their literal values. The equals() method in Object does the same thing. However, most classes (like String) override the equals() method to compare Objects based on their actual values, not their locations in memory.
|
|

New Topic/Question
Reply




MultiQuote






|