Java Method.isVarArgs()

Syntax

Method.isVarArgs() has the following syntax.

public boolean isVarArgs()

Example

In the following code shows how to use Method.isVarArgs() method.


import java.lang.reflect.Method;
// w  w w  . j  a  v a 2 s.  c o  m
public class Main {
  public static void main(String[] args) {
    String name = "java.util.Collections";
    try {
      Class cl = Class.forName(name);
      printMethods(cl);
    } catch (ClassNotFoundException e) {
      System.out.println("Class not found.");
    }
  }
  public static void printMethods(Class cl) {
    Method[] methods = cl.getDeclaredMethods();

    for (int i = 0; i < methods.length; i++) {
      Method m = methods[i];
      System.out.println(m.isVarArgs());

    }
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang.reflect »




Array
Constructor
Field
Method
Modifier
ParameterizedType
TypeVariable