我想使用lambda表达式对parentId排序menuList,parentId可以为null.我尝试下面的代码,但我无法找到为parentId添加nullcheck的方法,因为我得到nullpointer异常.
List<MenuList> menuList = session.createQuery("from MenuList").list();
menuList.sort((p1, p2) ->
p1.getParentId().compareTo(p2.getParentId()));
Run Code Online (Sandbox Code Playgroud)
你能帮我为parentId添加nullcheck吗?注意:我不想跳过parentId为null的菜单.
我试图在java中使用Split函数拆分字符串
String empName="employee name | employee Email";
String[] empDetails=empName.split("|");
Run Code Online (Sandbox Code Playgroud)
它给了我结果
empDetails[0]="e";
empDetails[1]="m";
empDetails[2]="p";
empDetails[3]="l";
empDetails[4]="o";
empDetails[5]="y";
empDetails[6]="e";
empDetails[7]="e";
.
.
.
Run Code Online (Sandbox Code Playgroud)
但是当我尝试遵循代码时
String empName="employee name - employee Email";
String[] empDetails=empName.split("-");
Run Code Online (Sandbox Code Playgroud)
它给了我
empDetails[0]="employee name ";
empDetails[1]=" employee Email";
Run Code Online (Sandbox Code Playgroud)
为什么java split函数不能拆分由"|"分隔的字符串
我正在尝试在Eclipse中构建项目,但它首先清理项目然后再繁殖.我想要修改那些被修改的文件.我怎样才能在Eclipse中实现同样的目标
I am trying to create static class in Java Web Application using eclipse. but it says
Illegal modifier for the class ClassName; only public, abstract & final are permitted
Run Code Online (Sandbox Code Playgroud)
can we create static class in web application ? if no why ?
我想从DB中获取值.我已经成功配置了hibernate.下面是我的hbm文件和pojo类.
<class name="UserMasterBean" table="EMPLOYEE_MASTER">
<id name="Id" type="long">
<column name="EMP_ID" length="10" />
<generator class="assigned" />
</id>
<property name="FirstName" type="string">
<column name="EMP_FIRST_NAME" length="30" not-null="true" />
</property>
<property name="SecondName" type="string">
<column name="EMP_SECOND_NAME" length="30" />
</property>
<property name="LastName" type="string">
<column name="EMP_LAST_NAME" length="30" />
</property>
<property name="empDob" type="date">
<column name="EMP_DOB" length="7" not-null="true" />
</property>
<property name="empDoj" type="date">
<column name="EMP_DOJ" length="7" not-null="true" />
</property>
<property name="empPermAdd1" type="string">
<column name="EMP_PERM_ADD1" length="50" not-null="true" />
</property>
<!--Other Properties removed-->
Run Code Online (Sandbox Code Playgroud)
下面是我的pojo课程
public class UserMasterBean {
private Long id;
private String …Run Code Online (Sandbox Code Playgroud)