I declared a Java class -
class Beach {
private String name, city;
public Beach(String name, String city) {
this.name = name;
this.city = city;
}
}
I imported this into jython and tried to create an object -
import Beach
b = Beach("candolim", "goa")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: java.lang.Object(): expected 0 args; got 2
Where is my two argument constructor?
Edit:
I follow these exact steps -
// Comment - Remove all files from directory to not create any confusion.
$ rm -rf *
$ vi Beach.java
class Beach {
private String name, city;
public Beach(String name, String city) {
this.name = name;
this.city = city;
}
}
$ javac *.java
$ javap Beach
Compiled from "Beach.java"
class Beach {
public Beach(java.lang.String, java.lang.String);
}
$ jython
>>> import Beach
>>> b = Beach()
>>> dir(b)
['__class__', '__copy__', '__deepcopy__', '__delattr__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__subclasshook__', '__unicode__', 'class', 'equals', 'getClass', 'hashCode', 'notify', 'notifyAll', 'toString', 'wait']