Java 1.5 Syntax help

Posted on 2005-05-16
Last Modified: 2010-03-31
Hello all,

What's the correct syntax for the declaration of:

1)  A public function (named "Fred")  that returns a double, and takes, as it's only argument, a Vector ((called "ethel") of Hashtables, where the hash key is a long, and the hash value is a Double?  I want to use the new generics, and I can't get this to work in Eclipse:

public double Fred(Vector<Hashtable<Long(), Double()>> ethel) { method body here}

2)  A foreach loop which loops through each hashtable in the vector "ethel" above, something like:

for (Hashtable<Long(), Double()> myHash: ethel) { stuff with myHash here}

Question by:vlg
    LVL 86

    Accepted Solution

         public double fred(Vector<Hashtable<Long, Double>> values) {
                for (Hashtable<Long, Double> h: values) {
                return 0.0;
    LVL 86

    Expert Comment

    Sorry - don't get confused between the function variable name and h.values() ;-)
    LVL 86

    Expert Comment

    This would have been better as an illustration:

    // Print the entries:

    LVL 86

    Expert Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Suggested Solutions

    Title # Comments Views Activity
    method argument as final 1 54
    allStar challenge 1 26
    parentbit challenge 3 36
    for i loop in grovy 1 25
    For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
    Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
    This video teaches viewers about errors in exception handling.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now