-1

So I understand the basics of creating strings and integers like this....

private String name;
private int min;
private int max;

but how do you set up an array?

For example, if I wanted to set up an array of book titles how would you go about that? If I wanted to set up an attribute like "books: book[]" would it be something like this?

private books[] book;
Edd
  • 1,230
  • 10
  • 14
ANON
  • 75
  • 1
  • 9

1 Answers1

0

You can have an array of Books[] if you define the type (class) Books. For example:

public class Books{

    Books(){

    }

    public static void main(String[] args) {

        Books[] books = new Books[5];//an array of 5 objects of type Books
    }
}
c0der
  • 15,550
  • 6
  • 26
  • 53