Меню

Cannot resolve symbol string java ошибка

I recently downloaded IntelliJ IDEA to a different computer. On one computer it works fine on the other computer it is giving me this current issue.

When i open a new project with a template it automatically shows errors everywhere even though it allows the code to run and shows the output correctly: standard Java library classes like String and System are highlighted in red and the error tooltip says: «cannot resolve symbol».

I have tried «Invalidate caches/Restart», but it didn’t help.

Basic code showing errors in JDK classes

CrazyCoder's user avatar

CrazyCoder

382k168 gold badges964 silver badges881 bronze badges

asked Apr 13, 2020 at 1:22

Thompson's user avatar

Check the JDK configuration Classpath tab in Project Structure | SDKs:

JDK

Also check that project and modules use the same JDK.

If it’s empty, remove the JDK and add it again. It’s not recommended to use JetBrains Runtime as your JDK, download and configure some different standalone JDK instead, 2020.1 version can download JDK for you.

Important notice
The bundled JRE is used for running the IDE itself,
and it’s not sufficient for developing Java applications. Before you
start developing in Java, download and install a standalone JDK build.

answered Apr 13, 2020 at 1:32

CrazyCoder's user avatar

CrazyCoderCrazyCoder

382k168 gold badges964 silver badges881 bronze badges

0

I tried above, but no luck. I did get it working with File -> Invalidate Caches…
I selected all three checkboxes and then «Invalidate and Restart». That worked for me.

answered Apr 14, 2021 at 11:02

BBNKSR's user avatar

BBNKSRBBNKSR

711 silver badge1 bronze badge

1

Often this means there is an issue with your java compiler. Normally this issue arises on an initial Intellij install. You can install/update the java compiler to get it working properly.

Go to the editor and type Ctrl + Alt + Shift + A . Then, a little bar pops down and you can select to either install the compiler, or configure it. Both times this happened to me, I just clicked install and once it was done, everything worked. If the install doesn’t work, you can just reconfigure your compiler.

answered May 21, 2021 at 14:20

Jeremy's user avatar

JeremyJeremy

87610 silver badges29 bronze badges

Removing the Java SDK and adding it back under File->Project Structure did it for me.

answered Nov 11, 2021 at 4:48

Suresh Tiwari's user avatar

The only thing that worked for me (after hours of trying!) was to use the Android Studio’s embedded JDK. «Invalidate caches/Restart» did not solve the issue, even using the same JDK version which was not coming with Android Studio was giving the Cannot resolve symbol 'String' errors. Wonder what’s so special with this pre-packaged JDK! Hmmm

answered Feb 26, 2022 at 18:56

doctorram's user avatar

doctorramdoctorram

99213 silver badges13 bronze badges

For me the solution seems to have been creating a new Run Configuration.

I had tried deleting the SDKs, and re-adding the one I needed but that did not clear the error. But creating a new Run Configuration did the trick.

answered Jun 27, 2022 at 19:25

cptully's user avatar

cptullycptully

5036 silver badges24 bronze badges

I had this problem when I uninstalled JDK and re installed it, and when I was making a new project I had the uninstalled JDK file selected, which somehow caused the system to be in red and un run-able.

answered Nov 26, 2022 at 0:21

Jack Cacela's user avatar

2

triatri3

11 / 12 / 8

Регистрация: 16.11.2016

Сообщений: 892

1

04.02.2020, 08:05. Показов 5231. Ответов 4

Метки нет (Все метки)


Выводит ошибки везде, где встречаются string’и. Что не так?

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.company;
import java.util.Scanner;
 
class Person {
    int age;
    string name;
    Person(int age, string name){
        this.age = age;
        this.name = name;
    }
 
    public void setAge(int age) {this.age = age;}
    public void setName(string name) {this.name = name;}
    public int getAge() {return age;}
    public string getName() {return name;}
}
 
public class Main {
 
    public static void main(String[] args) {
 
        Person p = new Person("Test", 3);
        System.out.println(p);
        p.setAge(5);
        p.setName("Vasya");
        System.out.println(p);
    }
}

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



2402 / 1861 / 472

Регистрация: 17.02.2014

Сообщений: 9,028

04.02.2020, 08:17

2

Цитата
Сообщение от triatri3
Посмотреть сообщение

Что не так?

не string, а String))



1



triatri3

11 / 12 / 8

Регистрация: 16.11.2016

Сообщений: 892

04.02.2020, 09:00

 [ТС]

3

Большое спасибо.
Это, к сожалению, не решило всех ошибок. Ошибка в строке 18:
incomparatible types: java.lang.String cannot be convertered to int
Проблема в том, что почему-то «Test» сохраняется в переменную age, а она интовая, а 3 сохраняется в age (string). Менял местами строки в конструкторе и поменял местами переменные в классе, но всё равно не решило ошибку, вот что получилось:

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.company;
import java.util.Scanner;
class Person {
    String name;
    int age;
    Person(int age, String name){
        this.name = name;
        this.age = age;
    }
    public void setName(String name) {this.name = name;}
    public void setAge(int age) {this.age = age;}
    public String getName() {return name;}
    public int getAge() {return age;}
}
 
public class Main {
    public static void main(String[] args) {
        Person p = new Person("Test", 3);
        System.out.println(p);
        p.setAge(5);
        p.setName("Vasya");
        System.out.println(p);
    }
}



0



Модератор

Эксперт функциональных языков программированияЭксперт Python

33777 / 18814 / 3968

Регистрация: 12.02.2012

Сообщений: 31,558

Записей в блоге: 12

04.02.2020, 09:40

4

Лучший ответ Сообщение было отмечено triatri3 как решение

Решение

triatri3, у тебя конструктор класса (стр.6) требует первым параметром int, вторым — String. А при вызове (стр. 18)?

почитай Обрати внимание на п.2 и 3



2



2402 / 1861 / 472

Регистрация: 17.02.2014

Сообщений: 9,028

04.02.2020, 09:57

5



0



How to fix IntelliJ cannot resolve symbol

Thursday 08, October 2015   |   Post link

Ever since copying a Gradle project from one computer to another I have been getting ‘cannot resolve symbol String’ and similar messages in IntelliJ. Listed below are steps which *may* fix the problem:

  • Invalidate and refresh the IntelliJ’s caches

    File Menu -> Invalidate Caches / Restart
  • Project SDK selection
    Check project settings from File Menu -> Project Structure
    Ensure an SDK is selected for the Project SDK. If is selected, click the ‘New’ button, select JDK and then select the correct path to the JDK e.g. /opt/java/jdk1.8 or c:JavaJdk1.8

    intellij-project-settings.png
  • Corrupt JDK
    There may be a problem with your JDK installation, re-install JDK
  • Re-import the project

    Close the project if it is open in IntelliJ
    Delete the .idea folder in the project source code folder.
    Start IntelliJ and Import the project.

Import a new project in IDEA, Cannot resolve symbol ‘String’

Problem Description: Using IDEA to import a new project, it appearsStringFont style turns red and prompts,As shown below:

                  

Solution: My IDEA version is IntelliJ IDEA 2018.1.5 (Ultimate Edition), which will be in File—>Project StructureNo SDKChange the installation path of the JDK to the cost. After clicking OK, you will see that the font color of the String is restored.Cannot resolve symbol ‘String’This prompt will also disappear.

Intelligent Recommendation

IDEA «Cannot resolve symbol» solution

1. Problem description: IDEA cannot recognize other classes in the same package and displays it in red. Compile can be compiled. The mouse displays «Cannot resolve symbol XXX», restart IDEA,…

IDEA cannot resolve symbol «xxx»

Problem Description: Use IDEA tools to create a new maven project, new Java entities and tool classes, after being referenced in the Service directory, a red wavy line is always displayed, prompting: …

More Recommendation

Cannot Resolve Symbol ‘XXXX’ in Idea

About IDEA appears in CannotSolve Symbol ‘FileInputStream’, there are many problems in the packets and classes, this class is not a class you write. Solution Use Ctrl + Alt + Shift + S or File == &quo…

Intellij IDEA Cannot Resolve Symbol

First, check if the corresponding resource is downloaded: 1. Check if the POM.xml file is dependent on all. 2.POM.XML file Right click on Maven -> Reload Project. 3.idea work page Click on the &quo…

Cannot resolve symbol ‘String’ (this is rare)

Cannot resolve symbol ‘String’ (this is rare) (1) See here for special circumstances problem causes: It may be that installing a new jdk will cause the system to be unable to communicate with the old …

When a user refers to a variable that hasn’t been declared in the application, the “can’t find symbol” error occurs. To put it another way, the compiler isn’t aware of the variable’s declaration. For example:

class HelloCodeunderscored {
    public static void main( String args[] ) {
      int x = 15;
      int y =1 4;
      // result is not declared. It will show an error.
      result = x * y;
    }
}

What are possible solutions to this problem?

If you ever encounter this issue, you should review the code for the following scenarios:

  • Make sure you’ve declared the variable, for example, int i = 15;. If int has not been written, the error may show.
  • Also, see if the defined variable is outside the code, for example, if it is not a member of the HelloCodeunderscored class.
  • Make sure you’re using the right case. If you declare a variable as var but access it as Var, it is an example of such a scenario.
  • Numbers, dollar signs, and hyphens are not allowed in identifier values; check for them.

Errors in Compilation Time

The compiler examines and checks the code for various things during compilation, including reference types, type casts, and method declarations, to mention a few. This stage of the compilation process is crucial since it is here that we will encounter a compilation mistake.

Compile-time mistakes can be divided into three categories:

Syntax errors

One of the most common programming errors is failing to use a semicolon at the end of a statement; other typical errors include forgetting imports, mismatching parentheses, and omitting the return statement.

Type-checking errors

This is a method of ensuring that our code is type-safe. With this check, we provide that the kinds of expressions are consistent. If we define a variable of type int, we should never assign a value of type double or String to it.

Compiler will crash

Meanwhile, there’s a chance the compiler will crash. It is exceptionally uncommon, but it does happen. In this scenario, it’s good to know that the issue isn’t with our code but with something else.

Compilers follow a set of rules that are specific to each language. If a code doesn’t follow these requirements, the compiler won’t be able to convert it, resulting in a compilation error. The key to resolving the “Cannot find symbol” compilation problem is to figure out what’s causing it.

We may deduce the line of code where the problem occurred and which element is incorrect from the error message. Knowing the most common causes of this mistake will make it easier and faster to resolve.

Symbol Tables: An Overview

Compilers construct and maintain symbol tables, which are significant data structures for storing information related to identifiers in source code. This information is placed into symbol tables during lexical and syntactic analysis and subsequently used in the compilation process.

The identifiers of classes, interfaces, variables, and methods are bound to correspond entries in the symbol tables when the declarations are processed. When these identifiers appear in source code, the compiler looks them up in the symbol tables. It uses that information to confirm that a variable has been declared, establish the variable’s scope, and do type checking to ensure that an expression is semantically correct.

Symbol tables are also employed in the creation and optimization of code. The following is a simplified representation of a symbol table entry (or simply a symbol) in Java:

<symbol name (identifier), type, scope, [attributes]>

The comparable notation for a global variable declaration, such as final double ratio, would be <ratio, double, global, [final]>.

Error: Cannot Find Symbol

As the name implies, the cannot locate symbol error refers to a symbol that you cannot find. While there are a variety of causes for this, they all boil down to the Java compiler being unable to locate the symbol associated with a given identifier.

Two more fields are included in the compiler’s message for the cannot locate symbol error:

“symbol” refers to the name and type of the referenced identifier. On the other hand, “location” refers to the class where the identifier is used.

What causes the symbol cannot be found error?

The following are the most typical causes of the cannot locate symbol compile-time error:

  • Variable and method declarations missing,
  • References to variables and methods being out of scope
  • misspelled identifiers, and
  • omitted import statements.

Symbol Not Found vs. Cannot Find Symbol vs. Cannot Resolve Symbol

The cannot find symbol issue can also be encountered under the words symbol not found and cannot resolve symbol, as different Java compilers use somewhat different wording. Apart from the names, there is no difference between the meanings of these phrases.

Examples of “Cannot Find Symbol Error.”

Some of these “Cannot find symbol error” are as follows:

Handling an undeclared variable

The cannot find symbol error is raised when the Java compiler encounters an identifier it can’t find in the symbol table. As a result, the most common cause of this error is when a reference to an undeclared variable is made. Unlike some other languages, which don’t require explicit variable declarations or may enable declaring a variable after it’s been referenced (through hoisting ), Java requires that a variable be declared before being used or referenced in any form.

Figure (a) shows how an undeclared variable, in this case, the identifier average on line 9, causes two instances of the cannot find symbol error at the code’s locations. Figure (b) resolves the issue by declaring this variable with its data type (or inferring its kind with the var keyword in Java 10+).

Figure (a)

package codeunderscored;

public class CodeUndeclaredVariable {
    public static void main(String... args) {
        int x = 16;
        int y = 20;
        int z = 42;

        averageResults = (x + y + z) / 3.0; // averageResults is not declared
        System.out.println(averageResults);
    }
}

Figure (b)

package codeunderscored;

public class UndeclaredVariable {
    public static void main(String... args) {
        int x = 16;
        int y = 20;
        int z = 42;

        double averageResults = (x + y + z) / 3.0;
        System.out.println(averageResults);
    }
}

Dealing with an Out of scope variable

The compiler throws the cannot find symbol error when a Java application tries to access a variable declared in a separate (non-inherited or non-overlapping) scope. The effort to try and have access to the variable counter on lines 17 and 18 in Figure (a), which is only available within the statement declared on line 11, demonstrates this. Figure (b) indicates that moving the counter variable outside the for loop resolves the problem.

Figure (a)

package codeunderscored;

import java.util.Arrays;
import java.util.List;

public class CodeOutOfScopeVariable {
    public static void main(String... args) {
        final List<String> strings = Arrays.asList("Hello", "Codeunderscored");
        final String searchFor = "Codeunderscored";

        for (int counter = 0; counter < strings.size(); counter++) {
            if (strings.get(counter).equals(searchFor)) {
                break;
            }
        }

        if (counter < strings.size()) {
            System.out.println("The word " + searchFor + " was found at index " +    counter);
        } else {
            System.out.println("The word " + searchFor + " wasn't found");
        }
    }
}

Figure (b)

package codeunderscored;

import java.util.Arrays;
import java.util.List;

public class CodeOutOfScopeVariable {
    public static void main(String... args) {
        final List<String> strings = Arrays.asList("Hello", "Codeunderscored");
        final String searchFor = "Codeunderscored";
        int counter;

        for (counter = 0; counter < strings.size(); counter++) {
            if (strings.get(counter).equals(searchFor)) {
                break;
            }
        }

        if (counter < strings.size()) {
            System.out.println("The word " + searchFor + " was found at index " + counter);
        } else {
            System.out.println("The word " + searchFor + " wasn't found");
        }
    }
}

Figures (a) & (b): Error and resolution for not being able to discover a symbol for an out-of-scope variable.

Method name misspelled

A cannot locate symbol error is caused by misspelling an existing method or any valid identifier. Because Java identifiers are case-sensitive, any change of an existing variable, method, class, interface, or package name, as shown in Figure (b), will result in this error.

Figure (a)

package codeunderscored;

public class CodeMisspelledMethodName {

    static int fibonacci(int n) {
        if (n == 0) return 0;
        if (n == 1) return 1;
        return fibonacci(n - 1) + fibonacci(n - 2);
    }

    public static void main(String... args) {
        int fibResult = Fibonacci(20); // Fibonacci ≠ fibonacci
        System.out.println(fibResult);
    }
}

Figure (b)

package codeunderscored;

public class CodeMisspelledMethodName {
    static int fibonacci(int n) {
        if (n == 0) return 0;
        if (n == 1) return 1;
        return fibonacci(n - 1) + fibonacci(n - 2);
    }

    public static void main(String... args) {
        int fibResult = fibonacci(20);
        System.out.println(fibResult);
    }
}

Error Figure (a) and resolution Figure (b): Cannot find the symbol for a misspelled method name

An import statement is missing

Using classes, whether from the Java platform or a library, necessitates appropriately importing them using the import statement. If you don’t, the Java compiler will complain about a symbol that can’t be found. The java.util package is used in the code sample in Figure (a). The cannot locate symbol issue arises because the list class was created without specifying the necessary import. The problem is solved by adding the missing import statement line 4 in Figure (b).

Figure (a)

package codeunderscored;

import java.util.Arrays;

public class CodeMissingImportList {
    private static final List<String> CONSTANTS = Arrays.asList("A", "B", "C");

    public static void main(String... args) {
        System.out.println(CONSTANTS);
    }
}

Figure (b)

package codeunderscored;

import java.util.Arrays;
import java.util.List;

public class CodeMissingImportList {
    private static final List<String> CONSTANTS = Arrays.asList("A", "B", "C");

    public static void main(String... args) {
        System.out.println(CONSTANTS);
    }
}

Figure (a) Error and resolution (b): Cannot find the symbol for missing import

Examples that aren’t as common

The fundamental cause of the Java error cannot locate the symbol is sometimes found in unexpected or hidden areas. It is the case when a sentence is prematurely terminated by an unintentional semicolon Figure (a) or when object creation is attempted without a correct constructor invocation, which must include the new keyword Figure 6.

Figure (a)

package codeunderscored;

public class CodeLoopScope {

public static void main(String... args) {
        int start = 1, end = 10;
        for (int i = start; i <= end; i++); {
            System.out.print(i == end ? i : i + ", ");
        }
    }
}

Figure (b)

package codeunderscored;

public class CodeLoopScope {
    public static void main(String... args) {
        int start = 1, end = 10;
        for (int i = start; i <= end; i++) {
            System.out.print(i == end ? i : i + ", ");
        }
    }
}

Unable to locate a symbol for a prematurely stopped loop Figure (a) error and Figure (b) resolution

Figure (a)

package codeunderscored;

public class CodeObjectCreation {
    public static void main(String... args) {
        String s = String("Hello Codeunderscored!");
        System.out.println(s);
    }
}

Figure (b)

package codeunderscored;

public class CodeObjectCreation {
    public static void main(String... args) {
        String s = new String("Hello Codeunderscored!");
        System.out.println(s);
    }
}

Figure (a) Error and Figure (b) Resolution for Cannot Find Symbol Constructor Call

Other reasons for the problem “can’t find symbol” include:

Here are a few instances where the “Cannot detect symbol” appears unexplainable until you investigate further.

Inability to find symbol ‘var’:

You’re presumably trying to compile source code with an older compiler or an older—source level that employs local variable type inference (i.e., a var declaration). In Java 10, the var was introduced. Check your JDK version, build files, and IDE settings (if this happens in an IDE).

You’re not compiling or recompiling anything

New Java programmers occasionally don’t grasp how the Java toolchain works or haven’t set up a repeatable “build process,” such as utilizing an IDE, Ant, Maven, Gradle, etc. In this case, the programmer may end up chasing his tail, looking for an imaginary fault that is caused by improper recompilation of the code, and so on.

Another example is when you compile and run a class with (Java 9+) java SomeClass.java. You’re likely to get “Cannot resolve symbol” errors referring to the 2nd class if the class depends on another class that you haven’t compiled (or recompiled). The other source file(s) are not compiled automatically. In addition, the new “compile and execute” mode of the java command isn’t suited for launching programs with multiple source code files.

Incorrect dependencies

If you use an IDE or a build tool that manages the build path and project dependencies, you may have made a mistake with the dependencies; for example, you may have left out a dependency or chosen the incorrect version. Check the project’s build file if you’re using a build tool (Ant, Maven, Gradle, etc.). Further, examine the project’s build path setup if you’re using an IDE.

An issue with a previous build

It’s possible that a previous build failed, so a JAR file was created with missing classes. You would usually note such failure if you were using a build tool. If you acquire JAR files from someone else, you’ll have to rely on them constructing correctly and catching mistakes.

Use tar -tvf when you need to list the suspected JAR files contents if you suspect this.

Problems with Android

When programming for Android and seeing “Cannot discover symbol” issues linked to R, keep in mind that the context.xml file defines the R symbols. Check that your context.xml file is valid and in the right location and that the R class file for it has been generated and compiled. Because Java symbols are case sensitive, the corresponding XML ids are as well.

Other symbol problems on Android are most frequently caused by the factors mentioned above, such as missing or inaccurate dependencies, wrong package names, methods or fields that don’t exist in a specific API version, spelling/typing issues, and so on.

Problems with the IDE

People have reported occasions when their IDE becomes confused, and the compiler in the IDE cannot detect a class that already exists… or vice versa. If the IDE is set up with the incorrect JDK version, it can happen.

If the IDE’s caches become out of sync with the file system, it can happen.

There are IDE-specific solutions to this. The latter could be a problem in the IDE. For example, there is a typical case of how Eclipse incorrectly handled a Maven “test” tree. That particular bug, it appears, was fixed a long time ago.

Homoglyphs

It’s possible to have identifiers that appear the same but aren’t because they contain homoglyphs if you use UTF-8 encoding for your source files. You can circumvent this by limiting the source file encoding to ASCII or Latin-1 and utilizing Java uxxxx escapes for additional characters.

Hidden System classes

We’ve seen situations when the compiler complains that substring is an unknown symbol, such as this.

String s = ...
String s1 = s.substring(1);

It turns out that the programmer had written their version of String, which lacked substring operations. It has been done with System, Scanner, and other classes in the past.

Overall, don’t use the same names as common library classes when defining your classes! You can also use fully qualified names to remedy the situation. In the preceding example, the programmer may have written:

java.lang.String s = ...

java.lang.String s1 = s.substring(1);

What should I do about these errors?

  • In general, you should start by determining what triggered the compilation mistake.
  • Examine the line in the file that the compilation error notice refers to.
  • Determine which symbol the error message is referring to.
  • Figure out why the compiler says it can’t find the symbol; check the section above!
  • Then you consider what your code is trying to communicate.
  • Subsequently, try to figure out what changes you need to make to your source code to get it to do what you want.

It’s worth noting that not every “correction” is accurate. Consider the following:

for (int i = 1; i < 10; i++) {
    for (j = 1; j < 10; j++) {
        ...
    }
}

Assume the compiler says for j, “Cannot find symbol.” There are several ways we could “correct” this:

  • We suppose we could edit the inner for to for (int j = 1; j< 10; j++) – which would be correct.
  • Alternatively, we could put a declaration for j before the inner or outer for loops, which would probably be correct.
  • In the inner for loop, we could also change j to i, and that would be incorrect! and so forth. To discover the proper remedy, you must first understand what your code is attempting to accomplish.

Example: how erroneous variable scoping can result in a “Cannot find symbol” error

List<String> stringsVar = ...

for (int i = 0; i < stringsVar.size(); i++) {
    if (stringsVar.get(i).equalsIgnoreCase("fnord")) {
        break;
    }
}
if (i < strings.size()) {
    ...
}

For i in the if statement, this will result in a “Cannot find symbol” problem. Even though we earlier declared i, it only applies to the for statement and its body. The if statement’s reference to i cannot see that declaration of I because it is not within the project’s scope. A suitable correction would be to place the if statement within the loop or declare I before the loop begins.)

Example: an apparently strange “Cannot find symbol” issue caused by a typo

for (int i = 0; i < 100; i++); {
    System.out.println("i is " + i);
}

It will result in a compilation error in the println call, indicating that i is missing. But (as you point out), we did declare it!

The issue is the semicolon (;) that appears before the {. In that instance, a semicolon is an empty statement according to the Java language syntax. The for loop’s body is therefore made up of the empty statement. So here’s what that code actually means:

for (int i = 0; i < 100; i++);

// The previous and following are separate statements!!

{
    System.out.println("i is " + i);
}

The preceding declaration of i in the for statement is out of scope in the block. That is because the {…} block is not the body of the for loop.

Example: A “Cannot find symbol” error produced by a typo

int tmp = ...
  
int res = tmp(a + b);

The tmp in the tmp(…) phrase is incorrect, despite the earlier declaration. The compiler will look for a tmp method, but it will not locate one. The previously specified tmp is in the variables namespace, not the methods namespace. In one of the examples we saw, the programmer had forgotten to include an operator. This is what he wanted to write:

If you’re compiling from the command line, there’s another reason why the compiler might not discover a symbol. It’s possible that you just neglected to build or recompile another class.

For instance, suppose you have two classes, Secondary and Primary, and Secondary utilizes Primary. If you’ve never compiled Primary before and run javac Secondary.java, the compiler will likely fail because it can’t find the symbol Primary.

Compile Secondary and Primary together, for example, with javac Secondary.java Primary.java or javac *.java. Better still, utilize a Java build tool such as Ant, Maven, Gradle, etc.

Conclusion

The cannot find symbol error, also known as a symbol not found and cannot resolve symbol, is a Java compile-time error that occurs when the compiler cannot figure out what an identifier in the source code refers to. As with every other compilation fault, it’s critical to figure out what’s causing it, isolate the problem, and fix it effectively.

This error is mainly caused by referring to undeclared variables and methods, such as by misspelling them or failing to import their associated package. As seen in this article, once a problem has been identified, resolving it is relatively simple.

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Cannot read property tolowercase of undefined ошибка
  • Cannot read property createobjectasync of undefined ошибка при подписании