Help coderanch get a
new server
by contributing to the fundraiser

Alex Radomski

+ Follow
since Apr 24, 2003
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 Alex Radomski

Plz lemme know if there's a way of determining the size of a zip file in bytes...
(can I use RandomAccessFile.length() for zip files?) has getCompressedSize()
20 years ago
I'd say three String objects are created, Correct me if I'm wrong?

[ August 13, 2003: Message edited by: Alex Radomski ]
This link might help: unicode webpage

[ August 12, 2003: Message edited by: Alex Radomski ]
Congratualtions Dharma Cris, hey everyone..
Hi Andres, check Bunkhouse XML-link if you haven't yet..?
I was debating myself which cert. to take next. But I think I'll go with the flow...and stick with SCJD.
[ August 04, 2003: Message edited by: Alex Radomski ]
Excellent score!

20 years ago
Hi Unni,
When I run this code it does print all four lines...

Congratulations Penka!
20 years ago

That's excelent score, at least in my books.
Have you asked yourself what's next??

20 years ago
This is tricky one.
I will put numbers with brief explanation. Follow the numbers to see the sequence.

1. H constructor called
2. compiler places default constructor for H class, which calls super constructor G().You can't see it because JVM places implicitly call.
3. G() constructor executes, calls printS1() method
4. prints s1 which is still uninitialized "null". Constructor at line 3 hasn't finished yet
Gee...It seems I can't indent the lines..

[ July 23, 2003: Message edited by: Alex Radomski ]
[ July 23, 2003: Message edited by: Alex Radomski ]

[ July 23, 2003: Message edited by: Alex Radomski ]
I think the answer to this is simpler than it looks.
I will expand on what has been already said.
When we create a string with: String s1 = "AB";
We create one String object that is placed in the string pool and the variable s1 reference address will lead you straight to the string pool.
String s1 = "AB"; // and
String s2 = "A" + "B";
"AB" already in the pool, s2 will refer to the same address in the pool.
On the other hand when we create a string with: String s3 = new String ("AB");
We create one string object placed in the pool, and one in the non-pool which s3 will reference.
Bottom line:
When second String s1 = �AB�; is created reference s1 points to the same string in the string pool.
When String s2 = new String(�AB�); is created �s2� points to the new separate object (non-pool)

[ July 23, 2003: Message edited by: Alex Radomski ]
Hi Veena,
The best way to look at the instance operator is when object referred to by the variable reference on the left side of the instanceof (in this case c1) passes the IS-A test for the class on the right side.
I will expand with sample code. I hope this code will help you.
class A {}
class B extends A {}
class C extends B {
public static void main(String [] args)
C c1 = new C();
boolean b1 = c1 instanceof C; // true
boolean b2 = c1 instanceof B; // true
boolean b3 = c1 instanceof A; // true
boolean b4 = c1 instanceof Object; // All classes implicitly extend Object, so true
[ July 22, 2003: Message edited by: Alex Radomski ]
From static code you are never allowed to access "directly" non-static code.
Expl: lab() // this will call static version of lab()
You access non static code through handle - (instance/reference variable) of the enclosing class. In this case: "js"
js.lab() // calls non static version

Yes, static is not allowed because the Inner class is declared inside the method.
You can view the local-method-inner-class as just another local member of the method, which is not allowed to be declared static, private, public etc...
Hi Barkat,
It does not get mentioned in equals() contract becuase it belongs to hashCode() contract.