fork download
  1. class Main {
  2. public static void main(String[] args)
  3. {
  4. Person joe = new Person("Joe");
  5. Person sally = new Person("Sally");
  6. sally.touch(joe);
  7. }
  8. }
  9.  
  10. class Person {
  11. private String name;
  12. public Person(String name){
  13. this.name = name;
  14. }
  15. public void touch(Person other){
  16. System.out.printf("Touched %s%n", other.name);
  17. }
  18. }
Success #stdin #stdout 0.06s 4386816KB
stdin
Standard input is empty
stdout
Touched Joe