Hi,
I am new at programming and I have never done Java before. I am in my first Java class and we are asked to complete the following question...Complete the method printLargestAnimal below.

Consider the three Strings "dog", "cat", and "monkey". In lexicographical order, "monkey" is the largest of the three, since "monkey" appears the latest in an English dictionary. Write a method called printLargestAnimal, which takes three animal names as Strings and prints the largest one by size of name according to the compareTo method from String class. Thus, if the method were passed "dog", "cat", and "monkey", it would print "monkey".

I am totally lost and have no idea how to use the compareTo method. I don't understand how to get it to print out the animal name. Thank you

Have you looked through the Java API?
If you still can't get it to work, post what you have (remember to wrap it in [.code] [/code] tags) and we'll have a look at what may be missing.
You will also need to read this thread.

Thanks for the help. I got it working. I just had some stuff mixed around. Thanks again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.