There's a lot to be fixed in there.
You need to call all non-static methods on Stock
instances. First, you need to create one. Your constructor is broken: one should be declared as public Stock
instead of public void Stock
- the first is a constructor, the latter is a void
method that's (misleadingly) called Stock
.
Once you've done that, you can create an instance:
Stock s = new Stock(...arguments here...);
and use that to set price:
s.setPrice(5.12);
Printing s
automatically calls ìts toString
:
System.out.println(s);