From 1d020c3fbc26189f62acda62ea7620e9cbe6a252 Mon Sep 17 00:00:00 2001 From: Manoel Campos Date: Sat, 6 Apr 2024 15:23:47 -0300 Subject: [PATCH] Updates Launch Multi-File Source-Code Programs example Signed-off-by: Manoel Campos --- .../java/{Jdk22Class2.java => Jdk22SubClass.java} | 13 ++++++------- .../java/{Jdk22Class1.java => Jdk22SuperClass.java} | 8 ++++---- 2 files changed, 10 insertions(+), 11 deletions(-) rename src/main/java/{Jdk22Class2.java => Jdk22SubClass.java} (57%) rename src/main/java/{Jdk22Class1.java => Jdk22SuperClass.java} (57%) diff --git a/src/main/java/Jdk22Class2.java b/src/main/java/Jdk22SubClass.java similarity index 57% rename from src/main/java/Jdk22Class2.java rename to src/main/java/Jdk22SubClass.java index ecac4eb..9b9943f 100644 --- a/src/main/java/Jdk22Class2.java +++ b/src/main/java/Jdk22SubClass.java @@ -1,20 +1,19 @@ /** * A sample class that doesn't belong to any package, - * that uses {@link Jdk22Class1}, and enables you to compile + * that uses {@link Jdk22SuperClass}, and enables you to compile * all required classes and run this {@link #main(String[])} method * just typing at the terminal: {@snippet lang=bash : java Jdk22Class2.java} * * @author Manoel Campos * @see https://openjdk.org/jeps/458 */ -public class Jdk22Class2 { - private final Jdk22Class1 class1 = new Jdk22Class1("class1"); - +public class Jdk22SubClass extends Jdk22SuperClass{ public static void main(String[] args) { - new Jdk22Class2(); + var obj = new Jdk22SubClass("Manoel"); + System.out.println("Name: " + obj.getName()); } - public Jdk22Class2() { - System.out.println("Name: " + class1.getName()); + public Jdk22SubClass(String name) { + super(name); } } diff --git a/src/main/java/Jdk22Class1.java b/src/main/java/Jdk22SuperClass.java similarity index 57% rename from src/main/java/Jdk22Class1.java rename to src/main/java/Jdk22SuperClass.java index d058e0d..7e796e6 100644 --- a/src/main/java/Jdk22Class1.java +++ b/src/main/java/Jdk22SuperClass.java @@ -1,14 +1,14 @@ /** - * A class that is used by {@link Jdk22Class2} in order to show + * A class that is used by {@link Jdk22SubClass} in order to show * the Launch Multi-File Source-Code Programs feature. * @author Manoel Campos - * @see Jdk22Class2 + * @see Jdk22SubClass */ -public class Jdk22Class1 +public class Jdk22SuperClass { private final String name; - public Jdk22Class1(String name) { + public Jdk22SuperClass(String name) { this.name = name; }