5. 25. 6. The public Book class |
|
package yourpackagename;
public class Book {
String isbn;
String title;
int width;
int height;
int numberOfPages;
}
|
|
The Book class is a member of the yourpackagename package and has five fields.
Since Book is public, it can be instantiated from any other classes. |
- A public class must be saved in a file that has the same name as the class, and the extension must be java.
- A Java source file can only contain one public class.
- A Java source file can contain other classes that are not public.
|