【发布时间】:2017-12-10 15:26:00
【问题描述】:
将元素添加到列表时,我遇到了一个 nut 指针异常。
错误是 System.NullPointerException: Attempt to dereference an null object on out.add(Time.newInstance(17,00,00,00));
public class BusScheduleCache
{ //Variable
private Cache.OrgPartition part;
//Constructor
public BusScheduleCache()
{
Cache.OrgPartition newobj = Cache.Org.getPartition('local.BusSchedule');
part = newobj;
}
//methods
public void putSchedule(String busLine, Time[] schedule)
{
part.put(busline, schedule);
}
public Time[] getSchedule (String busline)
{
Time[] out = new List<Time>();
out = (Time[]) part.get(busline);
if (out == null)
{
out.add(Time.newInstance(8, 00, 00, 00));
out.add(Time.newInstance(17,00,00,00));
}
return out;
}
}
【问题讨论】:
标签: salesforce apex-code apex force.com