Ankita Jain wrote:
SCJP 6
Ankita Jain wrote:
I am very confused about how many total objects will be created within method main() including and excluding lost objects.
Ankita Jain wrote:
AND
if LINE 1 is changed to final String s="abc"; then how many objects will be there?
Please help!!!
[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
if LINE 1 is changed to final String s="abc"; then how many objects will be there?
Please help!!!
SCJP 6
Rafael Angarita.
SCJP 6.
SCJP 6
No of objects creation is effected by the fact that method iis static or non static???
SCJP 6
SCJP 6
All code in my posts, unless a source is explicitly mentioned, is my own.
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
SCJP 6
All code in my posts, unless a source is explicitly mentioned, is my own.
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ruben Soto wrote:Yeah, Ankit you are probably right. I am going to let you and Punit do some detective work on this, unfortunately it's time to go for me. Good luck with it, I will check the results first thing in the morning.
![]()
SCJP 6
SCJP 6
According to me without final keyword there should be 4 objects....am i right or wrong???
1. abc
2. def
3. abcdef
4 abcdef
SCJP 6
Ruben Soto wrote:
final String s="abc"; // LINE 1
String s1=s+"def"; //LINE 2
boolean b = (s1 == s1.intern()); // If string was created at loading time, b will be true (Maybe)
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Thanks
Sunil (SCJP 5)
sunil langeh wrote:Well friends, About whole discussion i am not clear about the first point, As far as my knowledge is concerned String objects are implicitly final i.e it can't be changed once it created so i don't think so that using final it will create any impact on s ...Am i right ? if not please clear it to me...
SCJP 6
Ankita Jain wrote:Punit
that means objects are created in println statement also???
I was not aware of this...
But then why "abcdef abcdef" ? they are different objects..aren't they??
SCJP 6
Ankita Jain wrote:
Java hobbyist.
(L5) String object with content "abcdef " created.
String object with content "abcdef abcdef" created.
SCJP 6
Punit Singh wrote:
(L5) String object with content "abcdef " created.
String object with content "abcdef abcdef" created.
I did not get this one Ronald.
Java hobbyist.
SCJP 6
All code in my posts, unless a source is explicitly mentioned, is my own.
Thanks,
Alps
All code in my posts, unless a source is explicitly mentioned, is my own.
Thanks,
Alps
All code in my posts, unless a source is explicitly mentioned, is my own.
Thanks,
Alps
All code in my posts, unless a source is explicitly mentioned, is my own.
Thanks,
Alps
All code in my posts, unless a source is explicitly mentioned, is my own.
Thanks,
Alps
All code in my posts, unless a source is explicitly mentioned, is my own.
PunitSoto (24 bytes)
Ruben (24 bytes)
PunitSingh (24 bytes)
PunitSoto Ruben (24 bytes)
final String s = "Punit"; //1 Punit
//5 PunitSoto space
SCJP 6