Monday, July 27, 2009

What is wrong with my java programming . it has one error?

this is the error





C:\bbs%26gt;javac libmainsys.java


libmainsys.java:43: array required, but int found


ypub[nElems] = new libary(title, author, ypub);


^


1 error





C:\bbs%26gt;





// to run this program: C%26gt;java libmainsys


//////////////////////////////////////...


class libary


{


private String booktitle;


private String bookauthor;


private int yearpub;


//--------------------------------------...


public libary(String title, String author, int ypub)


{ // constructor


booktitle = title;


bookauthor = author;


yearpub = ypub;


}


//--------------------------------------...


public void displaylibary()


{


System.out.print(" Book Title: " + booktitle);


System.out.print(", Book Author: " + bookauthor);


System.out.println(",Year Publisher : " + yearpub);


}





public String getLast() // get title


{ return booktitle; }


} // end class libary

What is wrong with my java programming . it has one error?
In these lines


// put libary into array


public void insert(String title, String author, int ypub)


{


ypub[nElems] = new libary(title, author, ypub);


nElems++; // increment size





how can you have the same name on an array on the left side and an integer inside the parans on the right side?

survey monkey

No comments:

Post a Comment