Exception in thread "main" java.lang.ClassCastException

G

ghashami_mina

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top