Class1.java
$timetable->start_time = $row{'deadline_time'} ? date('H:i', strtotime($row{'deadline_time'})) : ''; // start_time : Must be 24 hour format. For example: 18:00
$timetable->end_time = $row{'deadline_time'} ? date('H:i', strtotime($row{'deadline_time'})) : ''; // end_time : Must be 24 hour format. For example: 20:30
我需要使用返回到静态方法的documentationList,但是无法从静态上下文中获取非静态方法的错误
public List<UMRDTO> getDocumentationList(Session session)
{
List<UMRDTO> documentationList = null;
try
{
Query query = null;
query = session.createQuery(UMRSQLInt.DOCUMENTATION_LIST);
documentationList = query.list();
}
return documentationList;
}
答案 0 :(得分:2)
Static
个字段和方法与该类相关联。它们只能由classname和dot运算符调用。
Non static
个字段和成员链接到该类的instance
。他们需要调用类的对象。在同一个类中有一个特殊的引用,它引用当前正在执行的名为this
的对象。
Class是blueprint
,其实例是该蓝图的实现。创建对象时,在内存中分配空间。我们在对象上调用非静态方法。
您的方法getDocumentationList
是非静态的,这意味着它需要class1的对象,以便可以在该对象上调用它。您使用类名称调用它,而不是需要创建一个对象,然后调用该方法。
第二个选项是将getDocumentationList
声明为静态。