| Author |
Return type doubt
|
saloni jhanwar
Ranch Hand
Joined: Feb 09, 2012
Posts: 583
|
|
There is compile error in below program "Incompatible type", how to resolve it without changing return type "Object" for method "returnArray".
|
Tell the difficulties that i am difficult.
|
 |
Anayonkar Shivalkar
Bartender
Joined: Dec 08, 2010
Posts: 1295
|
|
saloni jhanwar wrote:how to resolve it without changing return type "Object" for method "returnArray"
hint : typecasting
|
Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD)
|
 |
Mohamed Sanaulla
Bartender
Joined: Sep 08, 2007
Posts: 2928
|
|
|
You cannot do without adding an explicit cast.
|
Mohamed Sanaulla | My Blog
|
 |
saloni jhanwar
Ranch Hand
Joined: Feb 09, 2012
Posts: 583
|
|
Anayonkar Shivalkar wrote:
saloni jhanwar wrote:how to resolve it without changing return type "Object" for method "returnArray"
hint : typecasting
Tried, but i think there is syntax problem
|
 |
Anayonkar Shivalkar
Bartender
Joined: Dec 08, 2010
Posts: 1295
|
|
Tried, but i think there is syntax problem wrote:Tried, but i think there is syntax problem
You should typecast it during the assignment itself :
Please refer to my next post
|
 |
Anayonkar Shivalkar
Bartender
Joined: Dec 08, 2010
Posts: 1295
|
|
By the way, in your second code, I see two references with same name obj
This would also work:
|
 |
saloni jhanwar
Ranch Hand
Joined: Feb 09, 2012
Posts: 583
|
|
Anayonkar Shivalkar wrote:
Tried, but i think there is syntax problem wrote:Tried, but i think there is syntax problem
You should typecast it during the assignment itself :
Thanks
|
 |
Anayonkar Shivalkar
Bartender
Joined: Dec 08, 2010
Posts: 1295
|
|
You are welcome.
By the way, its not necessary to typecast it during the assignment. Only problem with your second code was duplicate variable name.
|
 |
 |
|
|
subject: Return type doubt
|
|
|