Variable way Parametrized functions

Posted on 2005-04-06
Last Modified: 2010-03-31

I have noted in javascript is possible be written functions including a variable number of parameters like this:

function Suma(x)
      var sumandos = suma.arguments;
      var num_op = suma.arguments.length;
      var resultado = 0;
      for (var i=0; i<num_op; i++)
            resultado += sumandos[i];
      return resultado;

in same way, in visual c++ is possible to do it. My question is, if is possible in java swing to do this?
Question by:accarvajal
    LVL 15

    Accepted Solution

    LVL 15

    Expert Comment

    LVL 86

    Expert Comment

    If using prior to Java 1.5, you can use a List or an Object[] to pass the arguments

    Author Comment

    Thanks aozarov! I have java 1.5. points are yours. The only situation I have is due to I develop using eclipse, I noted in its configuration compilation compliance is 1.4. I tried to change it to 1.5 and started showing me a several code errors and warnings than in 1.4 didn't.
    LVL 15

    Expert Comment

    You need eclipse 3.1 (currently M6).

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    tenRun challenge 28 67
    JVM encoding. How to change encoding. 27 55
    Understanding websocket example in spring 1 21
    JAVA part two 5 11
    For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
    Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

    733 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

    17 Experts available now in Live!

    Get 1:1 Help Now