Spring IOC removes tight coupling by instantiating objects using xml. I have a doubt.Although this is a good idea but for any developer it is better to set values using a java class instead of an xml. So if we keep a centralized java class and using this class we create objects and reduce tight coupling is it not a better idea than spring IOC. I know there would be 1 disadvantage that it will have to be compiled again but still otherwise is it not a better idea than Spring IOC for java developers?
There's no right answer to which is best to use. I have seen very successful, and definitely not trivial, applications of Spring xml based DI and plain Java only based DI. In some ways I find the plain Java approach more straight forward but the Spring framework is pretty nice too, although I must say that the level of Spring support you get in your IDE makes a huge difference to how easy it is to work with.
Although this is a good idea but for any developer it is better to set values using a java class instead of an xml.
To the XML comment. Spring has been moving away from XML for a long time now and offers and annotation based Java config (since Spring 3.0). My Spring projects do not have any XML other than for configuring Spring Security and that will go away with the upcoming version (http://spring.io/blog/2013/07/05/spring-security-java-config-preview-oauth). Everything can now be done using Java configuration that means zero XML. Using Java config feels more natural to me and I like the ability to set break points as well.
People need to stop associating Spring with XML, or at least realize its not the only option. You can of course use one or the other or even mix them.
To find out more about Springs java config just Google for 'Spring @Configuration example' or something along those lines. There are tons of examples out there.