【问题标题】:"Cannot find symbol" of variable passed through method [closed]通过方法传递的变量的“找不到符号”[关闭]
【发布时间】:2013-05-21 20:00:29
【问题描述】:

为什么在引用通过构造函数传递的变量时会出错?

这是完整的 Customer.java 类:

import java.sql.ResultSet;
import javax.servlet.http.HttpServletRequest;

public class Customer {

    // SQL Variables
    private final String URL = "jdbc:mysql://localhost/books";
    private final String USER = "root";
    private final String PASSWORD = "P@ssw0rd1";

    // Class Variables
    int CustomerID;
    String customerEmail;
    String customerPassword;
    String customerFirstName;
    String customerLastName;
    String customerAddress;
    String customerCity;
    String customerProvince;
    String customerPostalCode;
    String customerPhoneNumber;
    String customerCreditCardNumber;
    String customerExpiryDate;
    String customerCreditCardType;

    // Class Constructors
    public Customer(int customerID) // Constructor for an Existing Customer
    {
        ResultSet customerData = MySQLQuery("select * from Customers where CustomerID=" . customerID);
    }
    public Customer(HttpServletRequest post) // Constructor for a new customer
    {

    }
    // Constructor Methods
    public ResultSet MySQLQuery(String query)
    {
        return queryResultSet;
    }
    // Getters and Setters
}

这是在 NetBeans 7.3 中在默认包内的 Customer.java 类中创建的 Java Web 项目。

【问题讨论】:

  • Java字符串连接与PHP不同,必须使用+连接字符串,而不是.

标签: java netbeans constructor compiler-errors


【解决方案1】:

您的意思似乎是.,而您的意思是+

可能是一位老 PHP 程序员? :-)

【讨论】:

  • 该死的比我快 1 秒
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-10-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多