implements Cloneable interface - Java Language Basics

Java examples for Language Basics:try with Resources

Description

implements Cloneable interface

Demo Code

class Clone implements Cloneable {
  int a;// w  w w  . jav  a 2 s . co  m

  Clone(int a) {
    this.a = a;
  }

  public static void main(String[] args) throws CloneNotSupportedException {
    Clone c = (Clone) new Clone(10).clone();
    System.out.println(c.a);
  }
}

Related Tutorials