A very small problem I am having. Here is an example:
A class representing a book
public class Book
{
private String title, author;
//Constructor for book
public Book (String name, String writer)
{
title = name;
author = writer;
}
Another class called Bookshelf representing a collection of books
public class Bookshelf
{
private Book[] shelf;
int number;
//Constructor for Bookshelf
public Bookshelf ()
{
shelf = new Book[10];
number = 0;
}
Main method:
public class Bookstore
{
public static void main (String[] args)
{
Bookshelf cases = new Bookshelf (); //<-how to retrieve the array inside bookshelf
System.out.println ("This is: " + Bookstore.somemethod (REALPARAM); //<--
}
//Static method
public static void somemethod (PARAMETER) //<--Array in bookshelf class as PARAMETER
{
//some code
}
}
So as you can see above, I have a static method called somemethod that is designed to accept the array present inside the Bookshelf class (Bookshelf constructor) as its parameter. How should I do this?? What should I put in the field PARAMETER as well as REALPARAM so that I can accomplish this??
Any form of help is greatly appreciated. I have researched online the whole day yesterday and also today. Thanks a lot.