Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: incompatible types!!

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default incompatible types!!

    In my class, at the line

    for (String coveredTestCase : getCoveredQCTestCases()) {

    I am getting this error

    TestBase.java:122: error: incompatible types
    for (String coveredTestCase : getCoveredQCTestCases()) {

    required: String
    found: Object

    Please help me how to debug this error.


  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: incompatible types!!

    What's
    getCoveredQCTestCases()
    returning?

  3. #3
    Member
    Join Date
    Mar 2011
    Posts
    198
    My Mood
    Daring
    Thanks
    7
    Thanked 4 Times in 4 Posts

    Default Re: incompatible types!!

    I could be wrong but just a suggestion.. when returning the object try to set it as a string. Example is:

    return((String) objectValue);

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,358
    Thanks
    182
    Thanked 834 Times in 777 Posts
    Blog Entries
    5

    Default Re: incompatible types!!

    Quote Originally Posted by macko View Post
    I could be wrong but just a suggestion.. when returning the object try to set it as a string. Example is:

    return((String) objectValue);
    Why introduce the complication of a runtime error (ClassCastException) when trying to fix a compile time error? As Mr777 pointed out, we have no clue what the method getCoveredQCTestCases returns other than its an Object - the original poster should provide more information if they want more information.

  5. #5
    Member
    Join Date
    Mar 2011
    Posts
    198
    My Mood
    Daring
    Thanks
    7
    Thanked 4 Times in 4 Posts

    Default Re: incompatible types!!

    Well it seems his trying to set a object as a string to me.
    Last edited by macko; November 30th, 2011 at 05:46 PM.

  6. #6
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,550
    My Mood
    Grumpy
    Thanks
    0
    Thanked 169 Times in 160 Posts

    Default Re: incompatible types!!

    incompatible types!!

    Duplicate post.
    Improving the world one idiot at a time!

Similar Threads

  1. java.lang.NoClassDefFoundError incompatible with
    By mackogacko in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 30th, 2011, 06:29 AM
  2. incomparable types
    By frozen java in forum What's Wrong With My Code?
    Replies: 0
    Last Post: July 22nd, 2011, 10:44 PM
  3. incompatible types
    By frozen java in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 25th, 2011, 10:40 AM
  4. incompatible types Exception
    By world.java in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 17th, 2010, 01:33 PM
  5. Incompatible Types
    By Kimimaru in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 28th, 2010, 10:52 AM