• 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

printAL question

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

This is from page 163 of Head First Java.  I don't understand what is happening with public static void printAL(ArrayList<String> al).  I've never seen printAL and am not sure
if the code is just creating that or if it's part of the java.util library. Overall I'm not sure what it means or is happening as I've never seen a static void line similar to that. Just looking to understand what is happening.  

Thanks for any explanation.

 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This is the start of a method declaration. What it says is "I am declaring a method named printAL with a single parameter of type String. The method should be treated as public and as static, and it doesn't return a value (that's what void means)."

So yes, the code is creating that method. It's not part of the standard Java API because you don't need to declare those things in your code, they are already declared in somebody else's code.

In Head First Java there should be a description of what it means to declare a method; you may have already passed over that and not absorbed it or not noticed it. So look around in the book, maybe look in the index for "method declaration" or some form of those two words.
 
Brian King
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks so much. I appreciate it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic