如何从另一个带有参数的类中调用方法?

时间:2019-06-02 01:07:02

标签: android programmatically

我是一名初学者android编程。如何从另一个带有参数的类中调用方法

我尝试了method()来工作。但我不知道如何使用参数

@class b

Word2Vec

}

我想打A类电话

在A类中怎么称呼它?

2 个答案:

答案 0 :(得分:2)

您可以使用this site来学习基础知识。

public class A(){
        public A(){   //Empty constructor
        }

        public void someMethod(){
        }

        public void someMethodThatTakesString(String string){
        //do something with the string passed
        }

        public static void anotherMethod(){
        }
    }
    //You call this class and it's method
    A.anotherMethod(); //because this method is static
    A classA = new A();
    classA.someMethod();
    String someString = "I am string"
    someMethodThatTakesString(someString)

答案 1 :(得分:0)

通过创建此类的实例

A a = new A();

或使用静态方法

A.methid(params);`
相关问题