Originally posted by Neha Sawant: Hi all' int index=1; String a=new String(5); String b=a[index];//1 S.o.p(b); It prints null but i thought there will be a compiler error at line 1 b is not of the type  Thanks in advance Neha
Maybe i don't understand your question, buy anyway... String b=a[index];//1 String assign to a String, nothing wrong with line one //1. a[index] is a String Object. And b is a String reference. So, b has null now. I think it works ok.
Hi Neha, <code> String a=new String(5); </code> Here you are declaring a String array a and initializing it to hold 5 String objects. The default value of all objects, including String objects, is null. So a points to a 'null' object, a points to a 'null' object, etc. Hope that helps. ------------------ Jane Griscti Sun Certified Programmer for the Java� 2 Platform Co-author Mike Meyers' Java 2 Certification Passport [This message has been edited by Jane Griscti (edited December 02, 2001).]
thanx Feing and Jane. I was under the impression that a being of type array how it can be assigned to a plain string type. But after Jane's explanation i realised that it is not the entire  that is assigned but just a that is assigned to string b. Thanx once again Neha.