• Saves Valuable Time
  • Trusted Accuracy for 12 Years
  • 15-Day Money-Back Guarantee

Java Equivalent to C++ Constructors and Destructors

The closest match in Java to a C++ destructor is an implementation of java.io.Closeable.

C++ Java
class Foo
{
public:
    Foo() : Foo(0)   //call to other constructor
    {
    }
    Foo(int i)
    {
    }

    ~Foo()   //destructor
    {
    }
};
class Foo implements java.io.Closeable
{
    public Foo()
    {
        this(0);   //call to other constructor
    }
    public Foo(int i)
    {
    }

    public final void close()
    {
    }
}


Use C++ to Java Converter to convert from C++ to Java.     

Additional resource: Java and C++ Equivalents


Copyright © 1997 – 2017 Tangible Software Solutions Inc.