Anish Agrawal

+ Follow
since Apr 25, 2007
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Anish Agrawal

Hi All,

final static Integer x4 = 8;

The compilation error is due to this statement.It doesnot compile and we
get the error "Type mismatch;cannot convert from int to Integer".

We can't assign an int value directly to an Integer type.
It can be done like this:

Integer x4=new Integer(8);

But it can't be used as a case constant.

Thanks and Regards,
Thanks a lot Srinivasan thoyyeti ...It has really helped me to differentiate between the heap and String Constant Pool objects.

But where exactly is this String Constnt pool i.e. where it resides?

One more question is:
String s="hello";

in above code when we do the boolean expression evaluation in if
statement then whether an object with value "hi" gets created on
String Constant Pool or not?
Hi All,

1. String s="abc";

2. String s1=new String("world");

In SCJP(v 1.4) book by KathySierra chapter no. 6 Java.lang -The Math class,Strings, and Wrappers :

For the statement at line 1 ,its represented diagramatically that a String object with value "abc" gets created on heap and refers s to it.In the statement at line 1 "new String()" is not used then how come String object
gets created on heap.I feel that it just creates the String object in String Constant Pool if compiler doesn't find the literal "abc" in String Constant Pool.Where is this String Constant pool? whether this pool is a part of heap or is totally a different thing and is located somewhere else?

With this confusion my String basic concepts are getting disturbed.Pls explain???