I have a problem with final string. It is a mysql database client. I want to change query with clicking JButton.
public void run() {
final String query;
(...)
start.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
if(firstSel==null || selchose.getText().equals(selchose_str) || selbase.getText().equals(base_str)) {
query = "Select * FROM EMP";
}
(...)
The problem is with
query = "Select * FROM EMP";
It shows me
cannot assign a value to final variable query
How to solve the problem?
使查询String成为私有类字段或匿名内部ActionListener类的本地变量。
class YOurClassName{
private String query; //make here.....<<<<<<<<
public void run() {
(...)
start.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
if(firstSel==null || selchose.getText().equals(selchose_str) || selbase.getText().equals(base_str)) {
query = "Select * FROM EMP";
}
(...)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.