[英]Why when I run wathever program in NetBeans, the part of system.out.println() affears as class unidentified [on hold]
[英]Why is my System.out.println not working? Also this is not the main class and when i try to access it from the main class i don't get the output
代碼沒有給出 output
public class Init{
private String clientName;
private String clientNumber;
private double balance;
public Init(ASCIIDataFile file){
clientNumber = file.readString();
clientName = file.readString();
balance = file.readDouble();
}
public String getClientName(){
System.out.println(clientName); // `not working`
return clientName;
}
}
你錯過了this.
在構造函數中,因此getClientName()
中的clientName
為空
你的構造函數應該是這樣的:
public Init(ASCIIDataFile file){
this.clientNumber = file.readString();
this.clientName = file.readString();
this.balance = file.readDouble();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.