Results 1 to 4 of 4
- 01-11-2010, 06:22 AM #1
Member
- Join Date
- Nov 2009
- Location
- California
- Posts
- 55
- Rep Power
- 0
i have a small error but i can't figure out what is wrong [code provided]
So I am making a class and I can't figure out why there is an error.
The error is on the conditional of the last if statement.
Eclipse is telling me this:
The operator && is undefined for the argument type(s) int, boolean
Java Code:public static int search(int[] searchThisArray, int keyValue){ int negative1 = -1; for (int i = 0; i < searchThisArray.length; i++){ if (searchThisArray[i] == keyValue){ return i; break; //Will this break out of the for loop or only the if statement????????????????????????????????? } if ((i = ((searchThisArray.length) - 1)) && (searchThisArray[i] != keyValue)) return negative1; } }
- 01-11-2010, 06:23 AM #2
Member
- Join Date
- Nov 2009
- Location
- California
- Posts
- 55
- Rep Power
- 0
there is also a question inside of my code as well in the form of a comment
all help is greatly appreciated :]
- 01-11-2010, 06:43 AM #3
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
Use == to compare, and = to assign:
Java Code:if ((i == ((searchThisArray.length) - 1)) // etc
To see what "break" does read the fine tutorial. Or just write some code to experiment.
Post again if you get truly stuck, but the answer is on that page. (note that the labelled break statements mentioned are something to use sparingly.)
- 01-11-2010, 06:48 AM #4
Member
- Join Date
- Nov 2009
- Location
- California
- Posts
- 55
- Rep Power
- 0
Similar Threads
-
Hibernate mapping error Provided id of the wrong type with composite id
By zigzag in forum JDBCReplies: 1Last Post: 11-11-2008, 08:18 PM -
[SOLVED] Can't figure out what's wrong
By roach_van in forum New To JavaReplies: 10Last Post: 09-05-2008, 07:09 AM -
Urgent small code
By karingulanagaraj in forum New To JavaReplies: 7Last Post: 08-11-2008, 04:11 AM -
Please Help, can't figure out what I'm doing wrong.
By tamik0 in forum New To JavaReplies: 2Last Post: 07-11-2008, 09:41 AM -
small error
By ayoood in forum New To JavaReplies: 23Last Post: 05-27-2008, 12:18 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks