Hi!
An beginner question:
Pleas help me with this (-:
Error (the arrow points on the s in sqrt)
=====
tal.java:6: cannot find symbol
symbol : method sqrt(int)
location: class tal
System.out.println(i + ": " + sqrt(4));
^
1 error
Source
=====
class tal {
public static void main(String[] arguments) {
for (int i=0; i<11; i++) {
System.out.println(i + ": " + sqrt(4));
}
}
}
/Bjorn 15 28776
"Bjorn Jensen" <b.**************@gmx.netwrote in message
news:44**********************@nntp02.dk.telia.net. ..
Hi!
An beginner question:
Pleas help me with this (-:
Error (the arrow points on the s in sqrt)
=====
tal.java:6: cannot find symbol
symbol : method sqrt(int)
location: class tal
System.out.println(i + ": " + sqrt(4));
^
1 error
Is you sqrt function even made? If not then you should make it. If you have
made the function sqrt, you probably have made it static since you want to
reference from inside the main function. Unfortunately Java doesnt allow
that.
Just going to elaborate on what I said:
You can't use the arithmetic operators you would normally use on primitives
(i.e. double) on objects (i.e. Double). eg 1 + sqrt(4).
If you have made the function sqrt then you can make the function return an
int or similar. In that way Java will know what the return is
and the operator can then be applied.
Also I made the mistake of telling you that you cant reference anything in a
static context. That is still true but from main you can call static methods
which will resolve your problem e.g.
class tal {
public static void main(String[] arguments) {
for (int i=0; i<11; i++) {
System.out.println(i + ": " + sqrt(4));
}
}
public static int sqrt(int a){
// do something here with a
return 1;
}
}
Just remember that you can only use the variables given as parameters and
locally declared variables in a static method.
You can use the return value
Bjorn Jensen wrote:
Hi!
An beginner question:
Pleas help me with this (-:
Error (the arrow points on the s in sqrt)
=====
tal.java:6: cannot find symbol
symbol : method sqrt(int)
location: class tal
System.out.println(i + ": " + sqrt(4));
^
1 error
Source
=====
class tal {
public static void main(String[] arguments) {
for (int i=0; i<11; i++) {
System.out.println(i + ": " + sqrt(4));
}
}
}
/Bjorn
Try this:
class tal
{
public static void main(String[] arguments)
{
for (int i = 0; i < arguments.length; i++)
{
System.out.println(i + ": " +
java.lang.Math.sqrt(Double.parseDouble(arguments[i])));
}
}
}
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________ ________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Hi!
Your example works, but what are I'm doing wrong here:
import java.lang.Math;
class tal
{
public static void main(String[] arguments)
{
for (int i = 0; i < arguments.length; i++)
{
System.out.println(i + ": " + sqrt(Double.parseDouble(arguments[i])));
}
}
}
Resulting in (arrow at sqrt):
tal.java:10: cannot find symbol
symbol : method sqrt(double)
location: class tal
System.out.println(i + ": " + sqrt(Double.parseDouble(arguments[i])));
^
1 error
Thanks for help!
Bjørn
p.s. sorry, for my missing knowledge: is IchBin an name or is a joke;
IchBin = german for I'm?)
"IchBin" <we******@ptd.netskrev i en meddelelse
news:Mx********************@ptd.net...
Bjorn Jensen wrote:
>Hi! An beginner question: Pleas help me with this (-:
Error (the arrow points on the s in sqrt) ===== tal.java:6: cannot find symbol symbol : method sqrt(int) location: class tal System.out.println(i + ": " + sqrt(4)); ^ 1 error
Source ===== class tal { public static void main(String[] arguments) { for (int i=0; i<11; i++) { System.out.println(i + ": " + sqrt(4)); } } }
/Bjorn
Try this:
class tal
{
public static void main(String[] arguments)
{
for (int i = 0; i < arguments.length; i++)
{
System.out.println(i + ": " +
java.lang.Math.sqrt(Double.parseDouble(arguments[i])));
}
}
}
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________ ________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Hi!
I'm just trying to use the built-in funtions pow, sqrt etc
but can't get it to work.
Do you know some good examples somewhere, or can You give me one?
Greetings
Bjorn
"cp" <e-*****@nonplayercharacter.dkskrev i en meddelelse
news:44***********************@dreader1.cybercity. dk...
Just going to elaborate on what I said:
You can't use the arithmetic operators you would normally use on
primitives
(i.e. double) on objects (i.e. Double). eg 1 + sqrt(4).
If you have made the function sqrt then you can make the function return
an
int or similar. In that way Java will know what the return is
and the operator can then be applied.
Also I made the mistake of telling you that you cant reference anything in
a
static context. That is still true but from main you can call static
methods
which will resolve your problem e.g.
class tal {
public static void main(String[] arguments) {
for (int i=0; i<11; i++) {
System.out.println(i + ": " + sqrt(4));
}
}
public static int sqrt(int a){
// do something here with a
return 1;
}
}
Just remember that you can only use the variables given as parameters and
locally declared variables in a static method.
You can use the return value
Bjorn Jensen wrote:
Hi!
I'm just trying to use the built-in funtions pow, sqrt etc
but can't get it to work.
Do you know some good examples somewhere, or can You give me one?
Greetings
Bjorn
"cp" <e-*****@nonplayercharacter.dkskrev i en meddelelse
news:44***********************@dreader1.cybercity. dk...
>Just going to elaborate on what I said: You can't use the arithmetic operators you would normally use on primitives (i.e. double) on objects (i.e. Double). eg 1 + sqrt(4). If you have made the function sqrt then you can make the function return an int or similar. In that way Java will know what the return is and the operator can then be applied.
Also I made the mistake of telling you that you cant reference anything in a static context. That is still true but from main you can call static methods which will resolve your problem e.g.
class tal { public static void main(String[] arguments) { for (int i=0; i<11; i++) { System.out.println(i + ": " + sqrt(4)); } } public static int sqrt(int a){ // do something here with a
return 1; } }
Just remember that you can only use the variables given as parameters and locally declared variables in a static method. You can use the return value
Because the package java.lang is so fundamental, all the classes in
java.lang are automatically imported into every program. It's as if
every program began with the statement "import java.lang.*;". This is
why we have been able to use the class name String instead of
java.lang.String, and Math.sqrt() instead of java.lang.Math.sqrt(). It
would still, however, be perfectly legal to use the longer forms of the
names.
So you can only reference sqrt() as Math.sqrt() java.lang.Math.sqrt()
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________ ________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Bjorn Jensen wrote:
Hi!
I'm just trying to use the built-in funtions pow, sqrt etc
but can't get it to work.
Do you know some good examples somewhere, or can You give me one?
Greetings
Bjorn
"cp" <e-*****@nonplayercharacter.dkskrev i en meddelelse
news:44***********************@dreader1.cybercity. dk...
>Just going to elaborate on what I said: You can't use the arithmetic operators you would normally use on primitives (i.e. double) on objects (i.e. Double). eg 1 + sqrt(4). If you have made the function sqrt then you can make the function return an int or similar. In that way Java will know what the return is and the operator can then be applied.
Also I made the mistake of telling you that you cant reference anything in a static context. That is still true but from main you can call static methods which will resolve your problem e.g.
class tal { public static void main(String[] arguments) { for (int i=0; i<11; i++) { System.out.println(i + ": " + sqrt(4)); } } public static int sqrt(int a){ // do something here with a
return 1; } }
Just remember that you can only use the variables given as parameters and locally declared variables in a static method. You can use the return value
Please do not top post... It makes the messages hard to read.. Look at
this one and you will see the order problem. Who said what.
That said, because the package java.lang is so fundamental, all the
classes in java.lang are automatically imported into every program. It's
as if every program began with the statement "import java.lang.*;". This
is why we have been able to use the class name String instead of
java.lang.String, and Math.sqrt() instead of java.lang.Math.sqrt(). It
would still, however, be perfectly legal to use the longer forms of the
names.
So you can only reference sqrt() as Math.sqrt() java.lang.Math.sqrt()
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________ ________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Bjorn Jensen wrote:
Hi!
Your example works, but what are I'm doing wrong here:
import java.lang.Math;
class tal
{
public static void main(String[] arguments)
{
for (int i = 0; i < arguments.length; i++)
{
System.out.println(i + ": " + sqrt(Double.parseDouble(arguments[i])));
}
}
}
Resulting in (arrow at sqrt):
tal.java:10: cannot find symbol
symbol : method sqrt(double)
location: class tal
System.out.println(i + ": " + sqrt(Double.parseDouble(arguments[i])));
^
1 error
Thanks for help!
Bjørn
p.s. sorry, for my missing knowledge: is IchBin an name or is a joke;
IchBin = german for I'm?)
"IchBin" <we******@ptd.netskrev i en meddelelse
news:Mx********************@ptd.net...
>Bjorn Jensen wrote:
>>Hi! An beginner question: Pleas help me with this (-:
Error (the arrow points on the s in sqrt) ===== tal.java:6: cannot find symbol symbol : method sqrt(int) location: class tal System.out.println(i + ": " + sqrt(4)); ^ 1 error
Source ===== class tal { public static void main(String[] arguments) { for (int i=0; i<11; i++) { System.out.println(i + ": " + sqrt(4)); } } }
/Bjorn
Try this:
class tal { public static void main(String[] arguments) { for (int i = 0; i < arguments.length; i++) { System.out.println(i + ": " + java.lang.Math.sqrt(Double.parseDouble(argument s[i]))); } } }
Thanks in Advance... IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us _________________________________________________ _________________________
'If there is one, Knowledge is the "Fountain of Youth"' -William E. Taylor, Regular Guy (1952-)
Please do not top post... It makes the messages hard to read.. Look at
this one and you will see the order problem. Who said what.
That said, because the package java.lang is so fundamental, all the
classes in java.lang are automatically imported into every program. It's
as if every program began with the statement "import java.lang.*;". This
is why we have been able to use the class name String instead of
java.lang.String, and Math.sqrt() instead of java.lang.Math.sqrt(). It
would still, however, be perfectly legal to use the longer forms of the
names.
So you can only reference sqrt() as Math.sqrt() or java.lang.Math.sqrt()
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________ ________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Bjorn Jensen wrote:
Hi!
Your example works, but what are I'm doing wrong here:
import java.lang.Math;
class tal
{
public static void main(String[] arguments)
{
for (int i = 0; i < arguments.length; i++)
{
System.out.println(i + ": " + sqrt(Double.parseDouble(arguments[i])));
}
}
}
Resulting in (arrow at sqrt):
tal.java:10: cannot find symbol
symbol : method sqrt(double)
location: class tal
System.out.println(i + ": " + sqrt(Double.parseDouble(arguments[i])));
^
1 error
Thanks for help!
Bjørn
p.s. sorry, for my missing knowledge: is IchBin an name or is a joke;
IchBin = german for I'm?)
"IchBin" <we******@ptd.netskrev i en meddelelse
news:Mx********************@ptd.net...
>Bjorn Jensen wrote:
>>Hi! An beginner question: Pleas help me with this (-:
Error (the arrow points on the s in sqrt) ===== tal.java:6: cannot find symbol symbol : method sqrt(int) location: class tal System.out.println(i + ": " + sqrt(4)); ^ 1 error
Source ===== class tal { public static void main(String[] arguments) { for (int i=0; i<11; i++) { System.out.println(i + ": " + sqrt(4)); } } }
/Bjorn
Try this:
class tal { public static void main(String[] arguments) { for (int i = 0; i < arguments.length; i++) { System.out.println(i + ": " + java.lang.Math.sqrt(Double.parseDouble(argument s[i]))); } } }
Thanks in Advance... IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us _________________________________________________ _________________________
'If there is one, Knowledge is the "Fountain of Youth"' -William E. Taylor, Regular Guy (1952-)
Please do not top post... It makes the messages hard to read.. Look at
this one and you will see the order problem. Who said what.
That said, because the package java.lang is so fundamental, all the
classes in java.lang are automatically imported into every program. It's
as if every program began with the statement "import java.lang.*;". This
is why we have been able to use the class name String instead of
java.lang.String, and Math.sqrt() instead of java.lang.Math.sqrt(). It
would still, however, be perfectly legal to use the longer forms of the
names.
So you can only reference sqrt() as Math.sqrt() or java.lang.Math.sqrt()
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________ ________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
IchBin wrote:
Bjorn Jensen wrote:
>Thanks for help! Bjørn p.s. sorry, for my missing knowledge: is IchBin an name or is a joke; IchBin = german for I'm?)
Its just a handle. Although it could be considered a statement... lol
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________ ________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Bjorn Jensen wrote:
>> Thanks for help! Bjørn p.s. sorry, for my missing knowledge: is IchBin an name or is a joke; IchBin = german for I'm?)
It is just a handle. Although it could be considered a philosophical
statement as: 'I am'... lol
Or folly like the original name of the "Monty Python Show" which had a
name of "It's". That is why when you see some of the original shows they
had a guy in the start of the show say "It's"...
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________ ________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
I suggest you use your favorite search engine to look for examples. using
Java + sqrt as criteria to google resulted in a lot
of different hits.
-cp
So you can only reference sqrt() as Math.sqrt() or java.lang.Math.sqrt()
>
That is not quite true any more. As of Java 1.5 you can use a static
import like:
static import java.lang.Math.*;
and refer to the method simply as sqrt(...). For more info: http://java.sun.com/j2se/1.5.0/docs/...ic-import.html
Cheers,
Peter
Thank you to all of you for helpfull advice ;-)
/Bjorn
"Bjorn Jensen" <b.**************@gmx.netskrev i en meddelelse
news:44**********************@nntp02.dk.telia.net. ..
Hi!
An beginner question:
Pleas help me with this (-:
Error (the arrow points on the s in sqrt)
=====
tal.java:6: cannot find symbol
symbol : method sqrt(int)
location: class tal
System.out.println(i + ": " + sqrt(4));
^
1 error
Source
=====
class tal {
public static void main(String[] arguments) {
for (int i=0; i<11; i++) {
System.out.println(i + ": " + sqrt(4));
}
}
}
/Bjorn
Peter Van Weert wrote:
>So you can only reference sqrt() as Math.sqrt() or java.lang.Math.sqrt()
That is not quite true any more. As of Java 1.5 you can use a static
import like:
static import java.lang.Math.*;
and refer to the method simply as sqrt(...). For more info: http://java.sun.com/j2se/1.5.0/docs/...ic-import.html
Cheers,
Peter
Thanks for the info. I forgot about that...
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________ ________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Andrew |
last post by:
VS.net
Win 2k3
I'm getting the following error when attempting to debug. I'm not
debugging remotely, just a local project.
"Unable to start debugging. Cannot find port. Check the remote...
|
by: Charlie |
last post by:
Hi:
I'm using the HTML File Field control as a file picker for uploading files
to a SQl Server image field. When page posts back to initiate upload, if
file is small (under about two megs) all...
|
by: David T. Ashley |
last post by:
Hi,
Red Hat Enterprise Linux 4.X.
I'm writing command-line PHP scripts for the first time.
I get the messages below. What do they mean? Are these operating system
library modules, or...
|
by: Nils Magnus Englund |
last post by:
Hello,
In the root of a web site (C:\Inetpub\wwwroot), I have a .NET 1.1
application. I've just added a .NET 2.0 application to another directory
under the web site root...
|
by: DongWook |
last post by:
Dear all,
I've a windows application with crystal viewer to show a report (using vb .net 2003). I made a setup project and installed on client machines (no .net and crystal report). The...
|
by: .Net Sports |
last post by:
I'm using Persits.upload module in ASP, and when i use the following
form pointed to the object I've always used, i get a "The system
cannot find the file specified" error pointing to the line of...
|
by: GHUM |
last post by:
The compile works, BUT linking fails:
2.5\Release\psycopg\_psycopg.def -Lc:\python25\libs -Lc:
\python25\PCBuild -Lc:/p
ostgres/83RC2/lib -lpython25 -lpq -lws2_32 -ladvapi32 -o build...
|
by: etri |
last post by:
import TurtleGraphics.*;
public class Square
{
private Turtle yertle;
public Square()
{
yertle = new Turtle (TGCanvas(700,40));
//yertle.penDown();
yertle.forward(40);
//yertle.penUp();
|
by: matthew brown |
last post by:
class Temperature{
// Convert temperature from Fahrenheit to Centigrade
//Author : Samuel N. Kamin, June 1 , 1996
public static void main(Stringargs) {
int temperature; //The Fahrenheit...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |