Added code to demo expected package error (#11045)

* Added code for demo package error

* Corrected the package declaration

* BAEL-4216 Corrected Formatting and Removed final and Super

* Added few comments as per PR

* Update Book.java

Formatted comments with spaces

Co-authored-by: ine12363914 <saikat.chakraborty@tesco.com>
This commit is contained in:
saikatcse03 2021-09-18 22:06:00 +05:30 committed by GitHub
parent 2c837e030f
commit da13dd1aaf
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,21 @@
// The next line is commented out to avoid the code to fail the build.
// package com.baeldung;
/**
* If the below package declaration is commented out and the above incorrect package
* declaration is uncommented, then the problem will replicate.
*/
package com.baeldung.bookstore;
public class Book {
private String title;
private String author;
private long isbn;
public Book(String title, String author, long isbn) {
this.title = title;
this.author = author;
this.isbn = isbn;
}
}

View File

@ -0,0 +1,14 @@
package com.baeldung.bookstore;
import java.util.Random;
public class LibraryAdmin {
public Book createBook(String title, String author) {
final long isbn = new Random().nextLong();
return new Book(title, author, isbn);
}
}