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

java.lang.CloneNotSupportedException: com.lbh.xxmanager.basic.alg.Node at java.lang.Object.clone_第1张图片

你可能感兴趣的:(异常,java,bug,object,jdk,CloneNotSupport)