Home > Java > javaTutorial > How to call method in java reflection

How to call method in java reflection

WBOY
Release: 2023-04-28 09:52:06
forward
1604 people have browsed it

1. Description

Ordinary methods in a class can only be called after the class instantiates an object. There are three instantiation methods (new, conle, reflection).

2. Instance

    public class Book {
private String title;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
Copy after login

The class has a no-argument constructor, so when instantiating an object, you can directly use the newInstance method provided by Class.

What are the advantages of Java

1. Simple. As long as you understand the basic concepts, you can write applications suitable for various situations;

2. Object-oriented ;

3. Distribution, Java is a network-oriented language;

4. Robustness, Java provides automatic garbage collection for memory management, preventing programmers from easily generating errors when managing memory. Error;

5. Security, Java used in network and distributed environments must prevent virus intrusion;

6. Architecture neutrality, as long as the Java runtime system is installed, Can run on any processor;

7. Portability, Java can be easily transplanted to different machines on the network;

8. Interpretation and execution, the Java interpreter directly interprets Java words Section code is interpreted and executed.

The above is the detailed content of How to call method in java reflection. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template