Home > Java > javaTutorial > What are the characteristics of java generic methods

What are the characteristics of java generic methods

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-04-15 10:21:55
forward
1317 people have browsed it

1. Description

The relationship between public and return value is very important and can be understood as a universal method. Only the described methods are generic methods, and the member methods used in generic classes are not generic methods.

This method will use generic T, and generic T can be used at this time. Just like the definition of generics, T here can be written as any identifier. Common parameters such as T, E, K, V, etc. are usually used to represent generics.

2. Example

class DataHolder{     
T item;        
  public void setData(T t) {  
      this.item=t;   
  }      
  public T getData() {   
     return this.item;  
   }        
     /**      * 泛型方法      * @param e      */   
   publicvoid PrinterInfo(E e) {    
       System.out.println(e); 
    } 
}
Copy after login

What is Java

Java is an object-oriented programming language that can write desktop applications, Web applications, Distributed systems and embedded systems applications.

That’s it for “What are the characteristics of Java generic methods”? Thank you for reading. If you want to know more about the industry, you can pay attention to this site. The editor will output more high-quality practical articles for everyone!

The above is the detailed content of What are the characteristics of java generic methods. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Latest Issues
Install JAVA
From 1970-01-01 08:00:00
0
0
0
Unable to install java
From 1970-01-01 08:00:00
0
0
0
Can java be used as the backend of the web?
From 1970-01-01 08:00:00
0
0
0
Is this in Java language?
From 1970-01-01 08:00:00
0
0
0
Help: JAVA encrypted data PHP decryption
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template