aiaiask.com©

开花即结果 提问即答案

请你写我的世界代码
原始问题:

请你写我的世界代码

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;     } }
请你写我的世界代码
https://www.aiaiask.com/ask/17327.html
AI / 模型iFLYTEK
时间 / DATEApril 23, 2023, 7:52 PM
语言zh-CN
IP / 区域广东 广州