Troubleshooting Error: Cannot Find Symbol in Java Code

  • Context: Java 
  • Thread starter Thread starter whatisreality
  • Start date Start date
  • Tags Tags
    Error Symbol
Click For Summary

Discussion Overview

The discussion revolves around troubleshooting a Java programming error related to the recognition of the symbols signum(double) and sqrt(double). Participants explore potential causes for the error, including issues with library imports and the correct usage of mathematical functions in Java.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant expresses confusion about the error message indicating that the symbols signum(double) and sqrt(double) are not recognized, despite having imported java.lang.Math.
  • Another participant suggests that the issue may stem from the compiler not being able to find the library code, even if the import statement is present.
  • Some participants clarify that "symbol" refers to the name of a variable or function, rather than mathematical symbols like ##\Sigma## or ##\int##.
  • There is a discussion about whether the user is attempting to use the actual mathematical symbol ##\sqrt()## instead of the correct Java syntax Math.sqrt().
  • One participant acknowledges forgetting to include "Math." before sqrt, which resolved their issue.

Areas of Agreement / Disagreement

Participants generally agree on the importance of using the correct syntax in Java, particularly the necessity of prefixing mathematical functions with "Math.". However, there is no consensus on the underlying cause of the initial error, as different participants propose various explanations.

Contextual Notes

Some limitations include potential misunderstandings about the terminology used in programming and the specific setup of the user's development environment, which may affect the compiler's ability to locate library functions.

Who May Find This Useful

New Java learners, programmers troubleshooting similar symbol recognition errors, and those interested in understanding the nuances of Java syntax and library imports.

whatisreality
Messages
286
Reaction score
1
My program says it doesn't recognise the symbol signum(double) or sqrt(double)! I have definitely done the whole import java.lang.Math; thing. And signum and sqrt aren't symbols anyway. Is that too vague? I can post the actual code.

It's only my second week learning java, so it's supposed to be pretty straightforward stuff.
 
Technology news on Phys.org
whatisreality said:
My program says it doesn't recognise the symbol signum(double) or sqrt(double)! I have definitely done the whole import java.lang.Math; thing. And signum and sqrt aren't symbols anyway. Is that too vague? I can post the actual code.

It's only my second week learning java, so it's supposed to be pretty straightforward stuff.
Yes, the source code and imports would help.
 
  • Like
Likes   Reactions: whatisreality
whatisreality said:
My program says it doesn't recognise the symbol signum(double) or sqrt(double)! I have definitely done the whole import java.lang.Math; thing. And signum and sqrt aren't symbols anyway. Is that too vague? I can post the actual code.
I'm guessing that when you compile your code, the compiler isn't able to find the library code. The term "symbol" is computerese for the name of a variable, function, what-have-you, not a symbol such as ##\Sigma## or ##\int##. Even if your source code has a line where you import some library, if your installation isn't set up correctly, the compiler won't be able to find the code for functions you're importing.
 
  • Like
Likes   Reactions: whatisreality
Are you trying to use the actual symbol ##\sqrt ()## in your source code instead of Math.sqrt()?

Java supports unicode but it doesn't support using the ##\sqrt()## symbol or +- signum as valid operators in expressions. It instead requires you to type Math.sqrt() or use + and - for a number's sign.
 
Last edited:
  • Like
Likes   Reactions: whatisreality
jedishrfu said:
Are you trying to use the actual symbol ##\sqrt ()## in your source code instead of Math.sqrt()?

Java supports unicode but it doesn't support using the ##\sqrt()## symbol or +- signum as valid operators in expressions. It instead requires you to type Math.sqrt() or use + and - for a number's sign.
You are a hero! I forgot to put Math.sqrt! I was just using sqrt. And now my code works!

Thanks for all the replies, really appreciate it :)
 

Similar threads

Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
12K
  • · Replies 1 ·
Replies
1
Views
7K
Replies
3
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 18 ·
Replies
18
Views
9K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 6 ·
Replies
6
Views
5K