java.lang.CloneNotSupportedException: com.lbh.xxmanager.basic.alg.Node at java.lang.Object.clone

问题描述:

使用Object的clone方法报错

该行代码报错

node = (Node) curr.clone();
 java.lang.CloneNotSupportedException: com.lbh.xxmanager.basic.alg.Node
	at java.lang.Object.clone(Native Method)
 <hr style=" border:solid; width:100px; height:1px;" color=#000000 size=1">




原因分析:

 * The class {@code Object} does not itself implement the interface
 * {@code Cloneable}, so calling the {@code clone} method on an object
 * whose class is {@code Object} will result in throwing an

官方注释,该类没有继承Cloneable接口,所以会抛出CloneNotSupportedException。



解决方案:

继承Cloneable接口

public class Node implements Cloneable

空气刘海

猜你喜欢

转载自blog.csdn.net/weixin_44671737/article/details/113769346