in

Método Java.lang.Class.getMethods ()


Descripción

los java.lang.Class.getMethods () devuelve una matriz que contiene objetos Method que reflejan todos los métodos miembros públicos de la clase o interfaz representada por este objeto Class, incluidos los declarados por la clase o interfaz y los heredados de superclases y superinterfaces.

El método devuelve una matriz de longitud 0 si este objeto Class representa una clase o interfaz que no tiene métodos miembros públicos, o si este objeto Class representa un tipo primitivo o vacío.

Declaración

A continuación se muestra la declaración de java.lang.Class.getMethods () método

public Method[] getMethods() throws SecurityException

Parámetros

N / A

Valor devuelto

Este método devuelve la matriz de objetos de método que representan los métodos públicos de esta clase.

Excepción

Excepcion de seguridad – Si está presente un gerente de seguridad.

Ejemplo

El siguiente ejemplo muestra el uso del método java.lang.Class.getMethods ().

package com.tutorialspoint;

import java.lang.reflect.*;

public class ClassDemo {

   public static void main(String[] args) {

      try {
         Class cls = Class.forName("java.awt.Label");
         System.out.println("Methods =");
      
         /* returns the array of Method objects representing the public 
            methods of this class */
         Method m[] = cls.getMethods();
         for(int i = 0; i < m.length; i++) {
            System.out.println(m[i]);
         }
      } catch (Exception e) {
         System.out.println("Exception: " + e);
      }
   }
} 

Compilemos y ejecutemos el programa anterior, esto producirá el siguiente resultado:

Methods =
public void java.awt.Label.addNotify()
public int java.awt.Label.getAlignment()
public synchronized void java.awt.Label.setAlignment(int)
public java.lang.String java.awt.Label.getText()
public void java.awt.Label.setText(java.lang.String)
public javax.accessibility.AccessibleContext java.awt.Label.getAccessibleContext()
public void java.awt.Component.add(java.awt.PopupMenu)
public java.lang.String java.awt.Component.toString()
public java.lang.String java.awt.Component.getName()
public java.awt.Dimension java.awt.Component.size()
public boolean java.awt.Component.contains(int,int)
public boolean java.awt.Component.contains(java.awt.Point)
public java.awt.Container java.awt.Component.getParent()
public java.awt.Point java.awt.Component.getLocation()
public java.awt.Point java.awt.Component.getLocation(java.awt.Point)
public void java.awt.Component.remove(java.awt.MenuComponent)
public void java.awt.Component.setName(java.lang.String)
public void java.awt.Component.list()
public void java.awt.Component.list(java.io.PrintStream)
public void java.awt.Component.list(java.io.PrintStream,int)
public void java.awt.Component.list(java.io.PrintWriter)
public void java.awt.Component.list(java.io.PrintWriter,int)
public void java.awt.Component.print(java.awt.Graphics)
public java.awt.Dimension java.awt.Component.getSize()
public java.awt.Dimension java.awt.Component.getSize(java.awt.Dimension)
public void java.awt.Component.resize(int,int)
public void java.awt.Component.resize(java.awt.Dimension)
public boolean java.awt.Component.action(java.awt.Event,java.lang.Object)
public void java.awt.Component.setSize(int,int)
public void java.awt.Component.setSize(java.awt.Dimension)
public void java.awt.Component.update(java.awt.Graphics)
public boolean java.awt.Component.isOpaque()
public void java.awt.Component.enable()
public void java.awt.Component.enable(boolean)
public void java.awt.Component.disable()
public java.awt.Point java.awt.Component.location()
public final java.lang.Object java.awt.Component.getTreeLock()
public java.awt.Toolkit java.awt.Component.getToolkit()
public java.awt.peer.ComponentPeer java.awt.Component.getPeer()
public synchronized void java.awt.Component.setDropTarget(java.awt.dnd.DropTarget)
public synchronized java.awt.dnd.DropTarget java.awt.Component.getDropTarget()
public java.awt.GraphicsConfiguration java.awt.Component.getGraphicsConfiguration()
public boolean java.awt.Component.isValid()
public boolean java.awt.Component.isDisplayable()
public boolean java.awt.Component.isVisible()
public java.awt.Point java.awt.Component.getMousePosition() throws java.awt.HeadlessException
public boolean java.awt.Component.isShowing()
public boolean java.awt.Component.isEnabled()
public void java.awt.Component.setEnabled(boolean)
public boolean java.awt.Component.isDoubleBuffered()
public void java.awt.Component.enableInputMethods(boolean)
public void java.awt.Component.setVisible(boolean)
public void java.awt.Component.show()
public void java.awt.Component.show(boolean)
public void java.awt.Component.hide()
public java.awt.Color java.awt.Component.getForeground()
public void java.awt.Component.setForeground(java.awt.Color)
public boolean java.awt.Component.isForegroundSet()
public java.awt.Color java.awt.Component.getBackground()
public void java.awt.Component.setBackground(java.awt.Color)
public boolean java.awt.Component.isBackgroundSet()
public java.awt.Font java.awt.Component.getFont()
public void java.awt.Component.setFont(java.awt.Font)
public boolean java.awt.Component.isFontSet()
public java.util.Locale java.awt.Component.getLocale()
public void java.awt.Component.setLocale(java.util.Locale)
public java.awt.image.ColorModel java.awt.Component.getColorModel()
public java.awt.Point java.awt.Component.getLocationOnScreen()
public void java.awt.Component.setLocation(int,int)
public void java.awt.Component.setLocation(java.awt.Point)
public void java.awt.Component.move(int,int)
public java.awt.Rectangle java.awt.Component.getBounds()
public java.awt.Rectangle java.awt.Component.getBounds(java.awt.Rectangle)
public java.awt.Rectangle java.awt.Component.bounds()
public void java.awt.Component.setBounds(int,int,int,int)
public void java.awt.Component.setBounds(java.awt.Rectangle)
public void java.awt.Component.reshape(int,int,int,int)
public int java.awt.Component.getX()
public int java.awt.Component.getY()
public int java.awt.Component.getWidth()
public int java.awt.Component.getHeight()
public boolean java.awt.Component.isLightweight()
public void java.awt.Component.setPreferredSize(java.awt.Dimension)
public java.awt.Dimension java.awt.Component.preferredSize()
public boolean java.awt.Component.isPreferredSizeSet()
public java.awt.Dimension java.awt.Component.getPreferredSize()
public void java.awt.Component.setMinimumSize(java.awt.Dimension)
public java.awt.Dimension java.awt.Component.minimumSize()
public boolean java.awt.Component.isMinimumSizeSet()
public java.awt.Dimension java.awt.Component.getMinimumSize()
public void java.awt.Component.setMaximumSize(java.awt.Dimension)
public boolean java.awt.Component.isMaximumSizeSet()
public java.awt.Dimension java.awt.Component.getMaximumSize()
public float java.awt.Component.getAlignmentX()
public float java.awt.Component.getAlignmentY()
public int java.awt.Component.getBaseline(int,int)
public java.awt.Component$BaselineResizeBehavior java.awt.Component.getBaselineResizeBehavior()
public void java.awt.Component.doLayout()
public void java.awt.Component.layout()
public void java.awt.Component.validate()
public void java.awt.Component.invalidate()
public java.awt.Graphics java.awt.Component.getGraphics()
public java.awt.FontMetrics java.awt.Component.getFontMetrics(java.awt.Font)
public void java.awt.Component.setCursor(java.awt.Cursor)
public java.awt.Cursor java.awt.Component.getCursor()
public boolean java.awt.Component.isCursorSet()
public void java.awt.Component.paint(java.awt.Graphics)
public void java.awt.Component.paintAll(java.awt.Graphics)
public void java.awt.Component.repaint()
public void java.awt.Component.repaint(long)
public void java.awt.Component.repaint(int,int,int,int)
public void java.awt.Component.repaint(long,int,int,int,int)
public void java.awt.Component.printAll(java.awt.Graphics)
public boolean java.awt.Component.imageUpdate(java.awt.Image,int,int,int,int,int)
public java.awt.Image java.awt.Component.createImage(java.awt.image.ImageProducer)
public java.awt.Image java.awt.Component.createImage(int,int)
public java.awt.image.VolatileImage java.awt.Component.createVolatileImage(int,int)
public java.awt.image.VolatileImage java.awt.Component.createVolatileImage(int,int,java.awt.ImageCapabilities) throws java.awt.AWTException
public boolean java.awt.Component.prepareImage(java.awt.Image,java.awt.image.ImageObserver)
public boolean java.awt.Component.prepareImage
(java.awt.Image,int,int,java.awt.image.ImageObserver)
public int java.awt.Component.checkImage(java.awt.Image,java.awt.image.ImageObserver)
public int java.awt.Component.checkImage
(java.awt.Image,int,int,java.awt.image.ImageObserver)
public void java.awt.Component.setIgnoreRepaint(boolean)
public boolean java.awt.Component.getIgnoreRepaint()
public boolean java.awt.Component.inside(int,int)
public java.awt.Component java.awt.Component.getComponentAt(int,int)
public java.awt.Component java.awt.Component.getComponentAt(java.awt.Point)
public java.awt.Component java.awt.Component.locate(int,int)
public void java.awt.Component.deliverEvent(java.awt.Event)
public final void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
public boolean java.awt.Component.postEvent(java.awt.Event)
public synchronized void java.awt.Component.addComponentListener(java.awt.event.ComponentListener)
public synchronized void java.awt.Component.removeComponentListener(java.awt.event.ComponentListener)
public synchronized java.awt.event.ComponentListener[] java.awt.Component.getComponentListeners()
public synchronized void java.awt.Component.addFocusListener(java.awt.event.FocusListener)
public synchronized void java.awt.Component.removeFocusListener(java.awt.event.FocusListener)
public synchronized java.awt.event.FocusListener[] java.awt.Component.getFocusListeners()
public void java.awt.Component.addHierarchyListener(java.awt.event.HierarchyListener)
public void java.awt.Component.removeHierarchyListener(java.awt.event.HierarchyListener)
public synchronized java.awt.event.HierarchyListener[] java.awt.Component.getHierarchyListeners()
public void java.awt.Component.addHierarchyBoundsListener
(java.awt.event.HierarchyBoundsListener)
public void java.awt.Component.removeHierarchyBoundsListener
(java.awt.event.HierarchyBoundsListener)
public synchronized java.awt.event.HierarchyBoundsListener[] java.awt.Component.getHierarchyBoundsListeners()
public synchronized void java.awt.Component.addKeyListener(java.awt.event.KeyListener)
public synchronized void java.awt.Component.removeKeyListener(java.awt.event.KeyListener)
public synchronized java.awt.event.KeyListener[] java.awt.Component.getKeyListeners()
public synchronized void java.awt.Component.addMouseListener(java.awt.event.MouseListener)
public synchronized void java.awt.Component.removeMouseListener(java.awt.event.MouseListener)
public synchronized java.awt.event.MouseListener[] java.awt.Component.getMouseListeners()
public synchronized void java.awt.Component.addMouseMotionListener(java.awt.event.MouseMotionListener)
public synchronized void java.awt.Component.removeMouseMotionListener
(java.awt.event.MouseMotionListener)
public synchronized java.awt.event.MouseMotionListener[] java.awt.Component.getMouseMotionListeners()
public synchronized void java.awt.Component.addMouseWheelListener(java.awt.event.MouseWheelListener)
public synchronized void java.awt.Component.removeMouseWheelListener(java.awt.event.MouseWheelListener)
public synchronized...

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

chart 645

Como esconder fotos y vídeos no iPhone e protegê-los com senha? Guia passo a passo

apple touch icon@2

python – ¿Cómo agregar a PYTHONPATH en Windows, para que encuentre mis módulos / paquetes?