Skip to content

Added 'final' to EasySound. #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/main/java/chapter05/morning/EasySound.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
public class EasySound
{
private SourceDataLine line = null;
private byte[] audioBytes;
// audioBytes is declared immutable by the final keyword. In Java, class properties declared immutable can be
// assigned only once. Generally, this should be done as much as possible. Also, final declares the reference
// immutable; the property cannot be reassigned by the object it points to can be changed (does not apply to
// primitives). For more about the final keyword, read https://en.wikipedia.org/wiki/Final_(Java)#Final_variables.
private final byte[] audioBytes;
private int numBytes;

public EasySound(String fileName)
Expand Down