[英]How can i create a method that modifies an object of another class(java)?
[英]how can I create object of a class in another class
我有一個名為user的類,另一個有user1的類。 我想在用戶類中創建user1的對象。 我只是做新的User1()。 但是沒有用。
創建,沒有引用的新對象應在main方法內編寫
package com;
public class User {
public static void main(String[] args) {
new User1();
}
}
package com;
public class User1 {
User1(){
System.out.println("kkk");
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.