malaya nayak wrote:how can i create my own class that can be instantiated like we are creating string objects..
String s= "abc";
MyClass c= "xyz";// here my object should get initialized....
It's not possible in Java. The reason it works for String is because this particular class gets special language support to behave partly like a primitive.
You can come quite close though. Instead of using new you use a static creation class for your objects. And if you use a so called static import you don't need to prefix static methods of a class. The end-result would be something like,
MyClass c= create("xyz");
It's not perfect but it's as close as Java will take you at the moment.