Skip to content

Instantly share code, notes, and snippets.

@minte9
Last active August 31, 2021 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minte9/4be7eaf71f4d7889d52203b195c563a7 to your computer and use it in GitHub Desktop.
Save minte9/4be7eaf71f4d7889d52203b195c563a7 to your computer and use it in GitHub Desktop.
/**
* Write constructor and method for Output class.
* The output() prints the <name> instance variable
*/
class App {
public static void main(String[] args) {
Output o = new Output("John");
o.output(); // John
}
}
/**
* SOLUTION
*/
class Output{
private String name;
public Output(String name) {
this.name = name;
}
public void output() {
System.out.println(name);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment