0% found this document useful (0 votes)
6 views

Module Onemodule Info.java

The document describes a Java module structure with two modules: 'module.one' and 'module.two'. 'module.one' exports a package 'mypack' containing a 'Person' class, while 'module.two' requires 'module.one' and includes a 'Main' class that creates a 'Person' instance and prints its name. The 'Person' class has constructors and methods to manage the name attribute.

Uploaded by

classgattapugari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Module Onemodule Info.java

The document describes a Java module structure with two modules: 'module.one' and 'module.two'. 'module.one' exports a package 'mypack' containing a 'Person' class, while 'module.two' requires 'module.one' and includes a 'Main' class that creates a 'Person' instance and prints its name. The 'Person' class has constructors and methods to manage the name attribute.

Uploaded by

classgattapugari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

// module-one/module-info.

java
module module.one {
exports mypack;
}

// module-one/mypack/Person.java
package mypack;

public class Person {


private String name;

public Person(String name) {


this.name = name;
}

public Person() {
this.name = "Unknown";
}

public String getName() {


return name;
}

public void setName(String name) {


this.name = name;
}
}

// module-two/module-info.java
module module.two {
requires module.one;
}

// module-two/Main.java
import mypack.Person;

public class Main {


public static void main(String[] args) {
Person person = new Person();
person.setName("P1");
System.out.println("Person's Name: " + person.getName());
}
}

module-one/
├── module-info.java
└── mypack/
└── Person.java
module-two/
├── module-info.java
└── Main.java

You might also like