Update the releaseYear field of the language variable to set a new value using newReleaseYear.
Passing arguments to method
Passing reference types in practice
Report a typo
Sample Input 1:
2011Sample Output 1:
2011Write a program in Java 17
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
ProgrammingLanguage language = new ProgrammingLanguage(1995);
Scanner scanner = new Scanner(System.in);
updateReleaseYear(language, scanner.nextInt());
System.out.println(language.getReleaseYear());
}
/*
* Do you remember the theory?
* Where inside this method should you update the language variable releaseYear field?
*/
public static void updateReleaseYear(ProgrammingLanguage pl, int newReleaseYear) {
pl = new ProgrammingLanguage(2000);
}
}
class ProgrammingLanguage {
private int releaseYear;
public ProgrammingLanguage(int releaseYear) {
this.releaseYear= releaseYear;
}
public int getReleaseYear() {
return releaseYear;
}
public void setReleaseYear(int releaseYear) {
this.releaseYear = releaseYear;
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.