我明白了 错误:局部变量 transactionType 可能尚未初始化
但问题是它是在我的 if 语句中初始化的!
if (transactionChar == 'w')
transactionType = "Withdrawal";
else if (transactionChar == 'd')
transactionType = "Deposit" ;
然后当我去打印出 transactionType 时,它不会让我这么做,因为它给了我这个错误! 我的声明声明看起来像这样。
String transactionType;
char transactionChar;
请帮忙。在过去的 4 个小时里我一直在试图弄清楚!
最佳答案
初始化变量:
String transactionType = "";
char transactionChar = '';
(不确定字符,因为我通常使用 C#)。
关于java - 帮助!错误: The local variable transactionType may not have been initialized,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5070722/