Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Java Variable
class Rextester { private String name; private int age; // In addition to having the side-effect of setting the attributes in question, // the setters return "this" (the current Person object) to allow for further chained method calls. public Rextester setName(String name) { this.name = name; return this; } public Rextester setAge(int age) { this.age = age; return this; } public void introduce() { System.out.println("Hello, my name is " + name + " and I am " + age + " years old."); } // Usage: public static void main(String[] args) { Rextester person = new Rextester(); // Output: Hello, my name is Peter and I am 21 years old. person.setName("Peter").setAge(21).introduce(); } }
run
|
edit
|
history
|
help
0
bookstore
Escaping Literals II
javajava
h
Value pair analysis
Alumnos Java con Input
do while
linkl
calc exp gxb2
vsecodertest2