简体   繁体   English

C无法解析为变量-Java

[英]c cannot be resolved to variable - java

I have problems with this java code: 我对此Java代码有疑问:

for(Clause c : clauses)
  {
  if(c.s == 0)
  {
    switch(c.formula.type)
    {

    //LITERAL
    case 0:

      {
          ArrayList<Clause> clauses_without_c = ((ArrayList<Clause>) clauses.clone());
          clauses_without_c.remove(c);
      }
    }
  }
}

And i got error "c cannot be resolved to variable" in line: 我在行中收到错误“ c无法解析为变量”:

clauses_without_c.remove(c);

What's the problem? 有什么问题?

I'll bet that clone() isn't doing what you think it is. 我敢打赌,clone()并没有按照您的想法做。

If clauses is an ArrayList, you should be reading the javadocs: 如果子句是ArrayList,则应阅读javadocs:

Returns a shallow copy of this ArrayList instance. 返回此ArrayList实例的浅表副本。

You should create a new container instance and deep copy all the values into it. 您应该创建一个新的容器实例,并将所有值复制到其中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM