简体   繁体   中英

Cannot Find Symbol for simple primitive type

I don't know if this is real life, but I'm getting a Cannot find symbol after I just declared a simple string and when I try to assign the value it gets the cannot find symbol. This happens even if it is static or another primitive type.I'm assuming it's something configuration issues.

找不到标志

In java class you can declare or define (initialize at the same time) variables but not set any values or initialize them later. The second line can only be done in a method body or a constructor.

Example 1:

public class Test
{
   String name;

   void doStuff(){
      name = "  ";
   }
}

Example 2:

public class Test
{
   String name = "set some value";
}

You can read more about it HERE .

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.

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