Java 如何从main方法调用main类中的泛型静态方法?
例如,在我的主课上Java 如何从main方法调用main类中的泛型静态方法?,java,Java,例如,在我的主课上 public class main { // main method public static <T extends Building<T>> T houseAll(T input) { // random information } public static void main(String[] args) { // This is where I will
public class main
{
// main method
public static <T extends Building<T>> T houseAll(T input)
{
// random information
}
public static void main(String[] args)
{
// This is where I will make the call
}
}
公共类主
{
//主要方法
公共静态T houseAll(T输入)
{
//随机信息
}
公共静态void main(字符串[]args)
{
//这是我打电话的地方
}
}
那么,如何从主类中的泛型静态方法在主方法中进行调用呢?使用:
public class main {
// main method
public static <T extends Building<T>> T houseAll(T input) {
// random information
return null;
}
public static void main(String[] args) {
// This is where I will make the call
houseAll(null);
}
}
公共类主{
//主要方法
公共静态T houseAll(T输入){
//随机信息
返回null;
}
公共静态void main(字符串[]args){
//这是我打电话的地方
houseAll(空);
}
}
请您将大楼的骨架包括在内,好吗?main.houseAll(newbuilding());这是令人困惑的,因为您有一个名为main
的类、一个名为main
的方法和另一个带有注释的方法(houseAll
)。