Reputation: 1331
I have a problem today because I do not know how to call a java class which extends a sublass. I know there is the $ sign for nested class but here I'm lost.
To be more clear, here are the classes :
Abstract class :
Subclass :
To be honest, I forgot a lot of thing about java but I see there is no constructor for the subclass. The problem is that I must use the sublass.
Here is the code
(defn apache-logistic-reg [data x0 lamb]
(let [f (Logistic$Parametric.)
start (def-start x0 lamb)
fitter (.create SimpleCurveFitter. f start)
points (double-array (extract-points data))]
(.fit fitter points)))
The problem is that I cannot call SimpleCurveFitter. because it has no constructor. And AbstractCurveFitter has no .create, plus if I remember it well abstract classes cannot be cast.
And if I remember well, the constructor of SimpleCurveFitter would have the name of its abstract class but maybe I'm wrong.
How can I do ?
Thanks you
Upvotes: 0
Views: 353
Reputation: 10613
You don't need to call a constructor in SimpleCurveFitter
, because it provides the static method create
to get an instance for you (which you're already trying to use). Just make a static method call to that method to get an instance:
(.create SimpleCurveFitter f start) ;; No '.' after SimpleCurveFitter
(. SimpleCurveFitter create f start) ;; Alternate syntax
(SimpleCurveFitter/create f start) ;; Most common syntax (pointed out by amalloy)
Upvotes: 2