原始问题:
请你写我的世界代码
public class MyWorld {
public static void main(String[] args) {
System.out.println("Welcome to my world!");
// Create two objects
Person person1 = new Person("John", 25);
Person person2 = new Person("Jane", 28);
// Print out the details of each object
System.out.println(person1);
System.out.println(person2);
}}
class Person {
private String name;
private int age;
public Person (String name, int age) {
this.name = name; // Assign the name value to our name variable
this.age = age; // Assign the age value to our age variable }
@Override // Override the toString() method of Object class public String toString() { return "Name: " + this.name + ", Age: " + this.age; } }
Prev:劳动教育的精神内涵150字