Java Troubleshooting Error: Cannot Find Symbol in Java Code

  • Thread starter Thread starter whatisreality
  • Start date Start date
  • Tags Tags
    Error Symbol
Click For Summary
The discussion centers around a Java programming issue where a user encounters an error stating that the symbols signum(double) and sqrt(double) are not recognized. Despite importing java.lang.Math, the user initially attempted to use sqrt without the Math prefix. It is clarified that in Java, functions like sqrt must be called as Math.sqrt(), as Java does not recognize the symbol sqrt on its own. The user realizes the mistake of omitting the Math prefix and confirms that correcting this resolves the issue, allowing the code to work properly. The conversation highlights the importance of proper syntax and function calls in Java programming for beginners.
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 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 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 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 :)
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

Replies
8
Views
2K
  • · 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