Results 1 to 4 of 4
Thread: incompatible types?
- 09-26-2012, 03:44 AM #1
Member
- Join Date
- Aug 2011
- Posts
- 4
- Rep Power
- 0
incompatible types?
My array that was initialized to hold a Persons class will not hold the class.
I am seriously confused why this is happening.
these are the lines of code that hate me:
array[0] = p.setPerson(null, new Person(), st1);
array[i] = p.setPerson(array[i - 1], new Person(), st1);
They are on line 12 and 20.
Java Code:public void run() { // parse the data into Person objects and display it Person p = new Person(); StringTokenizer st = new StringTokenizer(mData, DEFAULT_RECORD_SEPARATOR); StringTokenizer st1 = new StringTokenizer(st.nextToken(), DEFAULT_FIELD_SEPARATOR); Person[] array; array = new Person[10]; int startVerse = DEFAULT_STARTVERSE; array[0] = p.setPerson(null, new Person(), st1); out.println(cFormat.format(p.toArray(startVerse))); for(int i = 1; st.hasMoreTokens(); i++) { p = new Person(); startVerse = startVerse + 3; st1 = new StringTokenizer(st.nextToken(), DEFAULT_FIELD_SEPARATOR); array[i] = p.setPerson(array[i - 1], new Person(), st1); //out.println(cFormat.format(p.toArray(startVerse))); } }
-
Re: incompatible types?
Where are your error messages as it is quite hard for us to guess what is wrong without this very important information?
I will guess though. You aren't assigning a Person object to the array item but rather whatever is returned by the setPerson(...) method. What does this method return by the way?
- 09-26-2012, 05:42 AM #3
Member
- Join Date
- Aug 2011
- Posts
- 4
- Rep Power
- 0
Re: incompatible types?
I really appreciate you writing back. I solved the issue as soon as I hit submit. I used a setter which doesnt return anything so thats why it hated me but ill remember to put up the error code next time
-
Re: incompatible types?
In most situations setter methods shouldn't return anything.
Similar Threads
-
Incompatible types
By Yokomoko in forum New To JavaReplies: 10Last Post: 07-10-2012, 03:49 AM -
incompatible types
By angelicatomnob in forum New To JavaReplies: 3Last Post: 01-17-2012, 03:25 PM -
incompatible types!!
By sneha343 in forum New To JavaReplies: 7Last Post: 11-30-2011, 11:49 PM -
incompatible types
By effa in forum New To JavaReplies: 16Last Post: 02-03-2011, 09:50 AM -
Incompatible types
By bayan in forum New To JavaReplies: 5Last Post: 11-04-2010, 08:43 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks