Troubleshooting Error: Cannot Find Symbol in Java Code

  • Context: Java 
  • Thread starter Thread starter whatisreality
  • Start date Start date
  • Tags Tags
    Error Symbol
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
4 replies · 3K views
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.
 
Physics 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 :)