IT. Expert System.

Java basics

getDeclaredMethods()


The java.lang.Class.getDeclaredMethod() method returns a Method object that reflects the specified declared method of the class or interface represented by this Class object. The name parameter is a String that specifies the simple name of the desired method, and the parameterTypes parameter is an array of Class objects that identify the method's formal parameter types, in declared order

Syntax:
public Method getDeclaredMethod(String name, Class... parameterTypes) throws NoSuchMethodException, SecurityException


Example:

import java.lang.reflect.*;

public class ClassDemo {

   public static void main(String[] args) {
    
     ClassDemo cls = new ClassDemo();
     Class c = cls.getClass();

     try {          
        // parameter type is null
        Method m = c.getDeclaredMethod("show", null);
        System.out.println("method = " + m.toString()); 
    
        // method Integer
        Class[] cArg = new Class[1];
        cArg[0] = Integer.class;
        Method lMethod = c.getDeclaredMethod("showInteger", cArg);
        System.out.println("method = " + lMethod.toString());
     }
     catch(NoSuchMethodException e) {
        System.out.println(e.toString());
     }
   }

   private Integer show() {
      return 1;
   }
    
   public void showInteger(Integer i) {
      this.i = i;
   }
   public int i = 78655;
}


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 92 / 159176596. Delta: 0.00154 с