Join 132,178 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,455 people online right now. Registration is fast and FREE... Join Now!
public void addBook(String i, String t, char ty, String s, String a, String p, String db){ Book b=new Book (i, t, ty, s, a, p, db); a [count] = b; count++; }
public void deleteBook(String isbn){
}
public int getBook(String isbn){ for(int i=0; i<a.length; i++){ if(a[i].getIsbn().compareToIgnoreCase(isbn)==0){ return i; }
public void addBook(String i, String t, char ty, String s, String a, String p, String db){ Book b=new Book (i, t, ty, s, a, p, db); a [count] = b; count++; }
public void deleteBook(String isbn){
}
public int getBook(String isbn){ for(int i=0; i<a.length; i++){ if(a[i].getIsbn().compareToIgnoreCase(isbn)==0){ return i; }
As William Wilson mentionned your variable names are horrible and generate your problem
CODE
Book[] a= new Book[1000]; int count=0;
public void addBook(String i, String t, char ty, String s, String a, String p, String db){ Book b=new Book (i, t, ty, s, a, p, db); a [count] = b;
When you write
a [count] = b;
you are not referencing: Book[] a= new Book[1000];
but the String a in your parameters: public void addBook(String i, String t, char ty, String s, String a, String p, String db){
using "this" that says use the "a" instance variable instead of the "a" parameter would fix your problem... but use more appropriate variables name
CODE
Book[] a= new Book[1000]; int count=0;
public void addBook(String i, String t, char ty, String s, String a, String p, String db){ Book b=new Book (i, t, ty, s, a, p, db); this.a [count] = b;
This post has been edited by pbl: 10 Oct, 2008 - 01:56 PM
As William Wilson mentionned your variable names are horrible and generate your problem
CODE
Book[] a= new Book[1000]; int count=0;
public void addBook(String i, String t, char ty, String s, String a, String p, String db){ Book b=new Book (i, t, ty, s, a, p, db); a [count] = b;
When you write
a [count] = b;
you are not referencing: Book[] a= new Book[1000];
but the String a in your parameters: public void addBook(String i, String t, char ty, String s, String a, String p, String db){
using "this" that says use the "a" instance variable instead of the "a" parameter would fix your problem... but use more appropriate variables name
QUOTE
thats alot pbl, i will work on my names. u wre very helpfull.
CODE
Book[] a= new Book[1000]; int count=0;
public void addBook(String i, String t, char ty, String s, String a, String p, String db){ Book b=new Book (i, t, ty, s, a, p, db); this.a [count] = b;