Glen Fernandes

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

Recent posts by Glen Fernandes

Hello Amit,

It means that the only place you can use the operator/keyword new to instantiate an object of the class (with a private constructor) is in a method inside that class.

However it can't be a non-static method, since that requires an object that is already instantiated with new. So a static method is needed to return a constructed object.

If a code example helps:


You can read up on the Singleton design pattern which relates to this.

Regards,
Glen
Hi Sajid,

Entry is static nested interface, inside interface Map.
This is almost like a static-nested class inside a class.

Consider the following code:


You can reference this via Outer.Inner, and even instantiate an object of an anonymous inner class, for example:


Simply put, a static nested interface behaves similarly to a static nested class - except it is an interface. (Technically it is not an "inner"-interface, just as static nested classes are not "inner"-classes).

Regards,
Glen
Hi,

Quite simply, it's an operator precedence issue.
Operator == has the lowest precedence in that expression.

What you want instead is:


Otherwise the s.equals(s1)+" "+s is evaluated, yielding a new String with the value "true ". This is then compared to s1 with the == operator, which obviously yields false.

Regards,
Glen

[ April 16, 2005: Message edited by: Glen Fernandes ]
[ April 17, 2005: Message edited by: Glen Fernandes ]
Hey,

Think of Math.round(x) as being equivalent to a Math.floor(x + 0.5)
So Math.round(-2.9) would equal Math.floor(-2.4)

And you should know that the floor method will return the largest integer which is less than or equal to its argument (so in this case -3).

Regards,
Glen
Hiya,

Just sat and passed the SCJP 1.4 exam today morning: scored 96%.
Next up, SCJD!

Regards,
Glen
19 years ago