I am trying to implement the following method:

public void add (String a, b, c, d, e, f,...z) { 
    ...
}   

However, I get a compile time error... What am I doing wrong with this? (The parameter takes 26 strings).

Recommended Answers

All 3 Replies

That's not the correct syntax for multiple parameters - every parameter must have its type (String etc) specified explicitly, eg
void add(String a, String b...

With 26 parameters you may want to consider passing an array instead?

ps: Next time don't just say "I get an error". Always post the complete exact text of the error message.

Right, sorry. Thanks, I thought java would stay consistent with it's other conventions for declarations;
int a, b, c, d, .. z. Apparently not.

If you use so many parameters then,it would be convenient to use String...params as the arguments if you are going to do a similar operation on each of them or it follows a certain patternThen using for each looping,you can achieve your need.

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.