You will have a interface like
public interface Vehicle{
public void noOfWheels();
}
You will have classes implementing the interfaces
public class Car implement Vehicle{
public void noOfWheels(){
}
}
public class Truck implement Vehicle{
public void noOfWheels(){
}
}
A Helper Class
public class transport {
1)Vehicle vehicle;
2)setter for vehcile
public wheel(){
vehicle.noOfWheels();
}
}
A Calling Class
public class SpringDemo{
ApplicationContext app = new ClassPathApplicationContext ("spring.xml");
Transport transport= (Transport )app.getBean("transport");
transport.wheel();
}
Spring configuration file
public interface Vehicle{
public void noOfWheels();
}
You will have classes implementing the interfaces
public class Car implement Vehicle{
public void noOfWheels(){
}
}
public class Truck implement Vehicle{
public void noOfWheels(){
}
}
A Helper Class
public class transport {
1)Vehicle vehicle;
2)setter for vehcile
public wheel(){
vehicle.noOfWheels();
}
}
A Calling Class
public class SpringDemo{
ApplicationContext app = new ClassPathApplicationContext ("spring.xml");
Transport transport= (Transport )app.getBean("transport");
transport.wheel();
}
Spring configuration file
No comments:
Post a Comment