• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doubt in linked invocations

 
Greenhorn
Posts: 21
Eclipse IDE MySQL Database Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have seen a prog like this

public class Addition{
public int doAddition(int a,int b){
int c=a+b;
return c;
}

public static void main(String[] args){
System.out.println(new Addition().doAddition(1,2);
}
}

suppose there is some other class in another package imports this class and calls doAdddition by passing 2 integer variables say 6,4 and gets 10. what about this line- System.out.println(new Addition().doAddition(1,2);. do it always passes (1,2) to doAddition method..

 
anita mitra
Greenhorn
Posts: 21
Eclipse IDE MySQL Database Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is the program

public class SearchServiceImpl{
SearchServiceDAO searchServiceDAO = new SearchServiceDAOImpl();
/* assume
SearchServiceDAO package is imported in to this package(contains class SearchServiceDAOImpl which implements the interface searchServiceDAO

*/

public SearchServiceDAO getSearchServiceDAO() {
return searchServiceDAO;
}
public List<ServiceVO> searchServiceProviders(String serviceType) {

return searchServiceDAO.getServiceProvidersByServiceType(serviceType);
}

public static void main(String[] args){

SearchServiceImpl searchService = new SearchServiceImpl();
List<ServiceVO> serviceVOList = searchService.getSearchServiceDAO().getServiceProvidersByServiceType("FLIGHT");
for(ServiceVO serviceVO : serviceVOList){

System.out.println(serviceVO.getServiceId());
System.out.println(serviceVO.getServiceName());
System.out.println(serviceVO.getServiceType());
System.out.println(serviceVO.getServiceUrl());
}
}

}

i couldn't understand this line- List<ServiceVO> serviceVOList = searchService.getSearchServiceDAO().getServiceProvidersByServiceType("FLIGHT");


please explain. does this implies that it will always pass flight as service type to the method?
 
anita mitra
Greenhorn
Posts: 21
Eclipse IDE MySQL Database Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sushmita sen wrote:

cant understand. please explain

 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

System.out.println(new Addition().doAddition(1,2);. do it always passes (1,2) to doAddition method..

yes... any reason that makes you think it should pass something else? see its not a variable but a literal and don't change
 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You show some piece of code of yours and ask us is "FLIGHT" passed as argument all the time? I think you can pass "CAR" or "TRAIN" or even "BULLOCK CART" as long as it is a service type. In this case, ENUM constant ServiceType should have been used as service type to help the client programmers
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic