Hi,
I am tried to complie this pgm,but I am getting errors. Why?
public class Wr
{
public static void main(
String s[])
{
String str = new String("Hello World");
Double b2 = Double.valueOf("3.5");
Integer b4 = new Integer("77");
int x = 14;
int obj1 = str.hashcode();
int obj2 = b2.hashcode();
int obj3 = b4.hashcode();
int obj4 = x.hashcode();
System.out.println(obj1);
System.out.println(obj2);
System.out.println(obj3);
System.out.println(obj4);
}
}
Wr.java:13: cannot resolve symbol
symbol : method hashcode ()
location: class java.lang.String
int obj1 = str.hashcode();
^
Wr.java:14: cannot resolve symbol
symbol : method hashcode ()
location: class java.lang.Double
int obj2 = b2.hashcode();
^
Wr.java:15: cannot resolve symbol
symbol : method hashcode ()
location: class java.lang.Integer
int obj3 = b4.hashcode();
^
3 errors