• Post Reply Bookmark Topic Watch Topic
  • New Topic

what does each part of this method mean  RSS feed

 
Missy Read
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My mission is to really learn java. But for some reason the books and java.sun.com isn't giving me what I need as a beginner. I'm sure in the future I'll be living on java.sun.com and the many books I have purchased. Below I've listed a method and want to know what every part of the method means. Can somebody tell me if I'm wrong and if I am please tell me where I'm wrong and tell me the correct answer.


public List getAnimalNames(int AnimalID) throws DataUnavailableException
{
ArrayList listAnimals = new ArrayList();
______________________________________________

1. public - is an accessLevel
2. List - is a returnType
3. getAnimalNames - is a method Name
4. (int AnimalID) - Passing Information into a Method (paramlist)
5. throws - is used to send an exception back to the caller.
6. ArrayList - is a paramlist
7. listAnimals - is an Object Reference
8. new ArrayList(); - Creates an Animal object

If somebody can set me straight or tell me if this is right it would be greatly appreciated. I figure I have to know what each thing means or I'll never learn the language. Missy


_________________________________________
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Missy Read:
My mission is to really learn java. But for some reason the books and java.sun.com isn't giving me what I need as a beginner.


I'm curious - what books do you have?

1.-4. correct
5. throws - declares that this method *might* send an exception back to the caller
6. ArrayList - is the type of the following variable
7. correct
8. new ArrayList(); - Creates an ArrayList, a list of objects that is implemented using an array; presumedly this list is meant to hold a number of Animal objects in the future

Hope this helps...
 
Missy Read
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You - Ilja

The books I currently have our Just Java and Java Dem. Yes they talk about for example methods similiar to what I put on the post but instead of pointing to each word in the method saying this is this and this is that they give a lot of talk with few examples - In other words, I need to see code and an explanation what it all means (similiar to what I put on the post) not just a lot of talk, if you know what I mean. If you know of better books that go into detail with example code that points to everything in the code block saying what it is then please tell me what book. Also what java.sun and these books do for example is talk about a car and give graph examples. I need to see code and the graphs. Thank you again.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I learned Java starting with Core Java. The authors' philosophies seem to coincide with what you want. They try to give real world examples of Java code to illustrate the topics presented in each chapter. Perhaps you should give it a try. I'd like to add that I when I started Java I already had a strong background in C++. I don't know if that makes a difference, but I find myself reluctant to compare my experience learning Java to others who are picking it up as their first programming language.

Layne
 
Marilyn de Queiroz
Sheriff
Posts: 9082
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My first Java book was Teach Yourself Java in 21 Days. I have since lent it to someone who never returned it. But my best recollection is that it did something like what you are describing. I would have to say that Just Java 2 is a very good book, but it is not a good book for you if you have never done any programming.



In this example, my only addition to Ilja's comments would be that, like
ArrayList is the type of listAnimals in
ArrayList listAnimals
int is the type of AnimalID in
( int AnimalID )
the parameter list.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!