[英]NullPointerException when I try to call a method outside my main method
[英]i keep getting an error when I try to call a method into my main function
此功能的目标是获取呼叫中心环境中座席的座席状态
package avaya_connection;
公共类 Avaya_Connection {
public void agentUpdate(Agent agentState)//checking agent state
{
agentState.getAgentID();
int previousAgentState = LucentAgent.UNKNOWN;/*the previous state
will by default be unknown*/
if (agentState.getState() == previousAgentState)//getting the agent state
return ;
previousAgentState = agentState.getState();
String msg = "AgentState: ";
switch (previousAgentState) {//switch statement to find the current agent state
case Agent.LOG_OUT:
System.out.println("Agent is logged out");
break;
case Agent.READY://agent state returns ready
System.out.println("Agent is ready");
break;
case Agent.NOT_READY://agent state returns not read
System.out.println("Agent is not ready");
break;
case Agent.WORK_NOT_READY:
System.out.println("Agent work not ready");
break;
case Agent.BUSY:
System.out.println("Agent is busy");
break;
default:
// Received an event which is not to be processed.
}
public static void main(String[] args)
{
Avaya_Connection ac = new Avaya_Connection();
ac.agentUpdate(agentState);/*calling the method of checking
agent states*/
}
}
返回的错误是找不到符号,并且在其左为空白时需要一个参数
要调用实例的方法,首先需要声明并实例化它。
Avaya_Connection ac = new Avaya_Connection();
与参数相同
Agent agentState = new Agent();
然后您可以调用该方法并正确传递参数。
ac.agentUpdate(agentState);
你不能在没有实例的情况下调用方法,除非它是静态的。
您首先需要声明并实例化它。
Avaya_Connection ac = new Avaya_Connection();
Agent a = new Agent();
然后按如下方式调用您的方法。
ac.agentUpdate(a);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.