Hi, i am having trouble getting the following String array to run correctly and having compile error. My compile error is posted below.
stapler.java:94: error: cannot find symbol
System.out.println("Product name: " +stapler.getnames[0]);
^
symbol: variable getnames
location: variable stapler of type Stapler
stapler.java:105: error: cannot find symbol
System.out.println("Product name: " +stapler1.getnames[1]);
^
symbol: variable getnames
location: variable stapler1 of type Stapler
stapler.java:116: error: cannot find symbol
System.out.println("Product name: " +stapler2.getnames[2]);
^
symbol: variable getnames
location: variable stapler2 of type Stapler
3 errors
public class Stapler { String[] name; int numberItem; double inStock; double price; int numberItem1; double inStock1; double price1; int numberItem2; double inStock2; double price2; public String[] getnames(){ return(name); } public int getItemnumber(){ return(numberItem); } public double getprices(){ return(price); } public double getunits(){ return(inStock); } public double getVolume() { return (inStock * price); } public int getItemnumber1(){ return(numberItem1); } public double getprices1(){ return(price1); } public double getunits1(){ return(inStock1); } public double getVolume1() { return (inStock1 * price1); } public int getItemnumber2(){ return(numberItem2); } public double getprices2(){ return(price2); } public double getunits2(){ return(inStock2); } public double getVolume2() { return (inStock2 * price2); } Stapler(){ String[] name = {"Miller's Stapler", "Miller's Staples", "Miller's Paper"}; numberItem = 123456; inStock = 123; price = 4.75; numberItem1 = 654321; inStock1 = 321; price1 = 2.50; numberItem2 = 987654; inStock2 = 987; price2 = 1.37; } public static void main(String[] args) { Stapler stapler, stapler1, stapler2; stapler = new Stapler(); stapler1 = new Stapler(); stapler2 = new Stapler(); System.out.println("Product name: " +stapler.getnames[0]); System.out.println("Product Number: "+stapler.getItemnumber()); System.out.println("Price of one product: "+stapler.getprices()); System.out.println("Number of units in stock: "+stapler.getunits()); System.out.println("Total value of Staplers is: "+stapler.getVolume()); System.out.println(); // System.out.println("Product name: " +stapler1.getnames[1]); System.out.println("Product Number: "+stapler1.getItemnumber1()); System.out.println("Price of one product: "+stapler1.getprices1()); System.out.println("Number of units in stock: "+stapler1.getunits1()); System.out.println("Total value of Staplers is: "+stapler1.getVolume1()); System.out.println(); // System.out.println("Product name: " +stapler2.getnames[2]); System.out.println("Product Number: "+stapler2.getItemnumber2()); System.out.println("Price of one product: "+stapler2.getprices2()); System.out.println("Number of units in stock: "+stapler2.getunits2()); System.out.println("Total value of Staplers is: "+stapler2.getVolume2()); System.out.println(); } }