调用另一个方法并在thready run方法内传递字符串参数时出现此错误….错误为“将titlepartnerf的修饰符改为final”。。我尝试调用的方法,用于发送应在后台运行的推送通知。请帮忙…提前谢谢
String titlePartnerF= titlePartner;
final MerchantBeanPush pushBeanF = pushBean ;
// MULTHREADING CODE
// KAMLESH DAVE : 03-FEB-2019
Thread t = new Thread(new Runnable() {
public void run() {
/* * Do something inside the thread*/
PushNotifictionHelper.sendPushNotification("W",pushBeanF.getWebToken(),titlePartnerF,messageP, bodyPartner);
}
});
t.start();
System.out.println("we are outside from method now in background+++++++++++");
1条答案
按热度按时间2cmtqfgy1#
内部类中引用的任何变量都必须声明为final或实际上是final。
String titlePartnerF= titlePartner;
必须是final String titlePartnerF= titlePartner;
请看下面的解释:为什么java内部类需要“final”外部示例变量?