nathan rivera nathan rivera - 5 months ago 59
Java Question

Java <Identifier> expected for method

getting started on a homework assignment where I'm required to use set/get methods. I have started writing the script however I run into a "identifier expected" error. I'm probably doing this very wrong. Any suggestions?

public class Stock {

private String stockName;
private int quantity;
private double purchasePrice;
private double currentPrice;

public Stock(stockName, quantity, purchasePrice,currentPrice)


The public Stock methods is what is causing the error.


You are missing types for the arguments in your constructor.

public Stock(String stockName, int quantity, 
            double purchasePrice, double currentPrice) {
    this.stockName = stockName;
    this.quantity = quantity;
    this.purchasePrice = purchasePrice;
    this.currentPrice = currentPrice;