字符串等于Android工作室

问题描述 投票:-4回答:1

只是想知道为什么我得到

无法解析符号'等于'

在string.equals上。我正在使用android studio。

public class Transaction {

    String type;
    double amount;

    if(type.equals("Deposit")){


    };


}
java
1个回答
3
投票

你必须在以下函数中编写测试:

public class Transaction {

    String type;
    double amount;

    public void testType() {
        if(type.equals("Deposit")) {


        }
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.