assigning parameter default value in function declaration

Hi,

I want to declare a method in which there are 5 to 6 parameters present and most of the parameter remain same while calling that method. so I want to assign a default values to these parameter at method declaration, so user wont need to enter the values of these parameters while calling that method.

My function should look like:

publicboolean methodName( String var1 ="check", String var2 ="check", String var3 ="check", String var4 ="uncheck", String var5 ="check", String var6 ="check")

{

// Now I will compare the variable values and if it is "check" then i will click on the check box or if it is uncheck then i should uncheck the check box.

// and most the time values for these parameters should be the same.

Now what i want is when i call this method and if i want to change the sencond parameter only thru this method then i should be able to call my method like:

methodName( ,uncheck,,,,,);

// I didnt write the value of each parameter, bcoz my method should take these values automatically.

I tried to do it myself, but i was getting error while initializing the String variable in method arguments.

Error: Syntax error in token, delete this token.

Hope, i was able to explain my question, and if you any idea about this problem and your help would be much appreciated.

Thanks and Regards,

Ashish

[1754 byte] By [agrawal1a] at [2007-11-27 11:07:39]
# 1

> My function should look like:

> (non-Java syntax method omitted)

> then i should be able to call my method like:

> methodName( ,uncheck,,,,,);

Java doesn't have that kind of thing. One suggestion I would make is to make the method take an object (which contains the 6 strings) instead of taking 6 seperate strings. In that object, its constructor could set the values of the 6 strings to their defaults. Then the client calling it could set some of the values to non-default values, then invoke the method.

warnerjaa at 2007-7-29 13:23:32 > top of Java-index,Java Essentials,Java Programming...
# 2

But you can check if the values are null

such as

if (var1 == null)

var1 = "default1"

pbulgarellia at 2007-7-29 13:23:32 > top of Java-index,Java Essentials,Java Programming...
# 3

Thanks!

agrawal1a at 2007-7-29 13:23:32 > top of Java-index,Java Essentials,Java Programming...