Ajay Divakaran

+ Follow
since Jul 08, 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 Ajay Divakaran

How do I rectify this error?

java Client.SimpleSessionClient

Exception in thread "main" javax.naming.NoInitialContextException: Cannot instan
tiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lan
g.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at Client.SimpleSessionClient.main(SimpleSessionClient.java:7)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFac
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
... 5 more
15 years ago
I have Oracle9i installed.
When I run this program I get an sql exception on line 8 stating that "could not resolve service name"
String s="|-|-|";

Using Pattern and Matcher in java.util.regex.* how do i write a RE
to match one or more occurance of "|-|"
16 years ago
String tp ="... --- ...";

output : OOO..
should'nt it be O --- O

Pls. explain
If the default hashCode() produces distinct values for each object created
why do we need to override it when using Maps ?
If two objects having same instances are created naturally equals() ( which is overriden ) will return false and will not get stored in a map.
So is not efficient enough to just override equals() for high performance ( fast access ) because each object is in a distinct 'bucket' and searching and comparing with just one object in the 'bucket' is required ?
Does the default hashCode() return unique number for each new object created?
I thought the default hashCode() returns a unique number for each object created?
import java.util.*;
class GenLearn
public static void main( String args[] )
ArrayList<Integer> input = new ArrayList<Integer>();
List<Integer> output ;//= new ArrayList<Integer>();
output = process( input ); //error!!

public static <E extends Number> List<? super E> process( List<E> nums)
List<Integer> tp = new ArrayList<Integer>();
return tp; // error!!

Oh!! I forgot.
its called covariant return type
thank You!
If im correct, we can't overload based only on return type. But the example from K&B shows that it is possible and it is said to be an OVERRIDE !
How is it possible an overriden method having different return types ??
referring to the
getRental method in both classes

class Rental
private List rentalPool;
private int maxNum;
public Rental( int maxNum, List rentalPool )
this.maxNum = maxNum;
this.rentalPool = rentalPool;
public Object getRental()
return rentalPool.get(0);
class CarRental extends Rental
public CarRental( int maxNum, List<Car> rentalPool )
super( maxNum, rentalPool );
public Car getRental() // how can it be an override ??
return (Car)super.getRental();
im reading byte by byte
16 years ago
How can I browse through all the file systems such as C,D,E and so on..
How do I know what drives are present on the computer??
16 years ago
How do i read the number -1 from the file because end of file is also -1??
16 years ago