【问题标题】:How do I call a generic static method thats in the main class from the main method? [duplicate]如何从主方法调用主类中的通用静态方法? [复制]
【发布时间】:2018-07-11 14:45:34
【问题描述】:

例如在我的主课中,我有

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
    }

}

那么我将如何从主类中的通用静态方法调用主方法?

【问题讨论】:

  • 能否请你这么好心,包括Building的骨架?
  • main.houseAll(new Building());
  • 这很令人困惑,因为您有一个名为 main 的类、一个名为 main 的方法和另一个方法 (houseAll),并带有注释指出它是主要方法。

标签: java


【解决方案1】:

使用有什么问题:

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);
    }

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-14
    • 2012-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-03
    • 2016-07-23
    相关资源
    最近更新 更多