Exception in thread "main" java.lang.ClassCastException

Discussion in 'Java' started by ghashami_mina, Dec 24, 2007.

  1. Hi,
    i have a problem and i need your help
    please help me
    i get this exception: Exception in thread "main" java.lang.ClassCastException: java.awt.Color cannot be cast to java.lang.Comparable

    and my program is :
    import java.awt.Color;
    import java.util.TreeMap;


    public class Street extends buyable{

    int[] rent = new int[5];
    int rent_hotel;
    Color color;
    int buildCost;
    int sellPrice;
    static TreeMap <Color,Integer> numOfHouse = new TreeMap<Color,Integer>();
    int numberOfHouse=0;
    int numberOfHotel=0;


    public Street(String name,int number,int mortValue,int price,int rent0,int rent1,int rent2,int rent3,int rent4,int rent_hotel,int buildCost,Color color) {
    super(name, number, mortValue, price);
    rent[0] = rent0;
    rent[1] = rent1;
    rent[2] = rent2;
    rent[3] = rent3;
    rent[4] = rent4;
    this.rent_hotel = rent_hotel;
    this.color = color;
    this.buildCost = buildCost;
    this.sellPrice = buildCost / 2;
    numOfHouse.put(color ,new Integer(0));
    }

    public static void main(String[] args) {
    Street m = new Street("mian",43,4,3,1,2,3,4,5,6,7,Color.pink);
    Integer a= m.numOfHouse.get(Color.pink);
    }
    }
    what should i do to solve this problem?
    ghashami_mina, Dec 24, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Howells
    Replies:
    4
    Views:
    16,066
    HiteshMehra
    Aug 21, 2007
  2. Bob Dubery
    Replies:
    5
    Views:
    584
    Bob Dubery
    Jun 19, 2004
  3. gbattine
    Replies:
    5
    Views:
    5,535
    gbattine
    Jun 19, 2006
  4. gbattine
    Replies:
    8
    Views:
    5,788
    gbattine
    Jun 22, 2006
  5. Replies:
    2
    Views:
    455
Loading...

Share This Page