Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Declaring methods with parameters

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,is it possible to declare the parameter list of a method with more than one type like say "public void displayMessage(String courseName.Int courseGradePointAverage)"?
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


(String courseName.Int courseGradePointAverage)



Is it a dot? I suppose it should be read as a comma, right?
 
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can not do that. Rename the method. You can however reorder the parameters so that it is overloaded but that would be a very bad idea. Infact a very very bad idea. :roll: Just take it as a warning rather than a suggestion.
 
Marshal
Posts: 74365
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have people misunderstood Christopher Pam's original question?
Does it mean, "Can you have two parameters to a method?" To which the answer is yes. It should however (as Raghu Rao has implied) read:-. . . and welcome to the Ranch.
[ March 09, 2007: Message edited by: Campbell Ritchie ]
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Campbell for pointing that out. Never thought it that way. Well then then Rao and Campbell have already answered.
 
reply
    Bookmark Topic Watch Topic
  • New Topic