Java 如何从另一个类调用变量

Java 如何从另一个类调用变量,java,object,output,syntax-error,logic,Java,Object,Output,Syntax Error,Logic,当我运行java代码时,它没有输出任何值。 我有两个类一个类使用jOption输入值,另一个类使用第一个类输入值计算利息 第1类: public class Employee_Details { String custName; String custNuum; String priice; String Month; int custNum; double price; int reMonth; double total; double reAmount;

当我运行java代码时,它没有输出任何值。 我有两个类一个类使用jOption输入值,另一个类使用第一个类输入值计算利息

第1类:

    public class Employee_Details {
    
 String custName;
 String custNuum;
 String priice;
 String Month;
 int custNum;
 double price;
 int reMonth;
 double total;
 double reAmount;
 
    
    public void getDetails (){
        
       Finance_Period fin1 = new Finance_Period();
        
        custName = JOptionPane.showInputDialog("Please enter Customer Name");
         custNuum = JOptionPane.showInputDialog("Please enter Customer Number");
        custNum = Integer.parseInt(custNuum);
     priice = JOptionPane.showInputDialog("Please enter price of product");
     price = Double.parseDouble(priice);
        Month = JOptionPane.showInputDialog("Please enter number of repayment months");
        reMonth = Integer.parseInt(Month);
        
         reAmount = price/reMonth;
        
          if (reMonth >3){
            fin1.getInterest();
          }
            else  {
              total = price;
              
             
              
             JOptionPane.showMessageDialog(null,"Customer Name: " + custName + "\n" + "Customer Conatct: " + custNum + "\n" + "Product Amount: " + "R"+price + "\n" + "Repayment Months: " + reMonth + "\n" +"Monthly Repayments: " + "R" +reAmount + "\n" + "Total Due: " + "R" + total  ); 
          }
           
        
         
         
       
       
       
        
        
    }
    
}
二等舱:

public class Finance_Period {
   
double interest;
String name;
int num;
double product;
double amount;



public double getInterest(){
    Employee_Details cust1 = new Employee_Details();
    
    
   
   
   
   
        interest = (0.25 * cust1.reAmount) + cust1.reAmount;
       
           
    JOptionPane.showMessageDialog(null,"Customer Name: " + cust1.custName+ "\n" + "Customer Conatct: " + cust1.custNum + "\n" + "Product Amount: " + "R"+cust1.price + "\n" + "Repayment Months: " + cust1.reMonth + "\n" +"Monthly Repayments: " + "R" + cust1.reAmount + "\n" + "Total:" + "R" + (cust1.reAmount + interest) );
        
    
    return interest;
在第一个类中,有一个if语句,表示如果偿还月数大于3,则运行其他方法,一旦我输入了大于3的数字,它将运行getinterest方法,但输出为:

我相信我没有正确链接这两个类,但我不知道还能做什么, 我似乎找不到这里的逻辑错误,请帮我解决

这是我的主课

公共静态void main(字符串[]args){


}

您向我们展示的代码中没有构造函数、getter或setter。当您执行类似于
Employee_Details cust1=new Employee_Details()的操作时
员工详细信息类的
字段未初始化为您或程序用户提供的任何值,因此当您访问这些字段时,如执行
cust1.reAmount
时,您预计会发生什么情况?另外,您也不会从另一个类中的一个类调用任何方法。您还没有向我们展示您的主类,并且您的两个类都没有
main()
方法,因此我们甚至不知道您是如何运行此方法的。我有3个类:员工详细信息、兴趣和主,所以对于我的方法,我应该使用getter和setter,对吗?这几乎不能解决我在评论中提到的许多问题之一。你应该编辑这个问题以包含主类的代码,并尝试解决我提出的其他问题。我已经向你展示了主方法,这是最后一段代码。我实现了getter和setter,现在我正在尝试将我在员工详细信息中的内容链接到兴趣类。再说一次,您的类中没有构造函数。当您没有给类的字段指定任何有意义的值时,您希望得到哪些详细信息?在这一点上,我能给你的最好建议是“在继续编写代码之前,先阅读Java开发的基础知识”。
Employee_Details cust1 = new Employee_Details();
cust1.getDetails();
 Finance_Period fin1 = new Finance_Period();
 
 
 JOptionPane.showMessageDialog(null,"Customer Name: " + cust1.custName+ "\n" + "Customer Conatct: " + cust1.custNum + "\n" + "Product Amount: " + "R"+cust1.price + "\n" + "Repayment Months: " + cust1.reMonth + "\n" +"Monthly Repayments: " + "R" + cust1.reAmount + "\n" + "Total:" + "R" + (cust1.reAmount + fin1.interest) );