以下是一个返回客户id,客户名称,公司名称,一共六个字段数据的Java代码:

public class Customer {
    private String customerId;
    private String customerName;
    private String companyName;

    public Customer(String customerId, String customerName, String companyName) {
        this.customerId = customerId;
        this.customerName = customerName;
        this.companyName = companyName;
    }

    public String getCustomerId() {
        return customerId;
    }

    public void setCustomerId(String customerId) {
        this.customerId = customerId;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    @Override
    public String toString() {
        return "Customer{" +
                "customerId='" + customerId + '\'' +
                ", customerName='" + customerName + '\'' +
                ", companyName='" + companyName + '\'' +
                '}';
    }
}

使用方法:

Customer customer = new Customer("001", "John Doe", "ABC Inc.");
System.out.println(customer.getCustomerId());
System.out.println(customer.getCustomerName());
System.out.println(customer.getCompanyName());
封装一个返回客户id客户名称公司名称一共六个字段数据的java代码

原文地址: https://www.cveoy.top/t/topic/biaG 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录