Skip to content

Instantly share code, notes, and snippets.

@minte9
Last active Aug 31, 2021
Embed
What would you like to do?
/**
* 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