473,698 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

integers and arrays in Java - how?

I used Google and found some references for integer in Java.
But "int" not only does not work, it also prevents reading X and Y
coordinates of the mouse.
What i would like to do:
1) Get X and Y mouse coordinates into a variable that i can do real math on.
So far, i can do math on the values "read" and that result goes into
a "variable" that is useful *only* for display.
If i try "int" in that math, the values are then zero for everything
- even those where i do no calculation.
2) Use the calculated integer values as an index to a table or array.
It is acceptable to use an HTML "table" as the source for the lookup;
W(CalcFromX) and P(CalcFromX) would be the resulting values to be
displayed on the screen somewhere.

Can this be done, and eXactly how?
Mar 30 '06
36 2071
Robert Baer <ro********@ear thlink.net> writes:
Thomas 'PointedEars' Lahn wrote:
You could have RTFM first, and even if you had not, you could have
read and followed <URL:http://jibbering.com/faq/#FAQ4_43> before
you posted anything.
** ?RTFM? what is that? And how would a complete newbie know where to
** look or know anything about that URL?


This URL is a link to the FAQ of this newsgroup. It is posted twice a
week in the group, so anybody following the group for more than four
days would have been able to see it. Several regualars of the group
also have links to this FAQ in their signatures.
People new to Usenet wouldn't know that you are recommended to follow
a group for at least that long before starting to write, or that
groups often have FAQs. The tradiatiaion way of teaching them this is
to answer their questions by a reference to the FAQ. That's what it
is there for.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Apr 1 '06 #21
Robert Baer wrote:
Thomas 'PointedEars' Lahn wrote:
Robert Baer wrote:
Randy Webb wrote:
Robert Baer said the following on 3/31/2006 6:28 AM:
You had trouble because you were using, or attempting to use, a feature
that is not part of the language. Not because of a feature that might
be in a future release of the language unless you were reading a draft
copy of JavaScript2.0 in which case you should have known it wasn't in
use yet.
I had no idea that the "int" "feature" was not a part of the language. AFAIK, it is merely not part of a language version that is implemented
_in Web browsers_. You could have RTFM first, and even if you had not,
you could have read and followed <URL:http://jibbering.com/faq/#FAQ4_43>
before you posted anything.

** ?RTFM? what is that?


Read The Fine/F***ing Manual. STFW (Search The Fine/F***ing Web).

Using any prefixes for your replies is unwanted. Attribution lines and
Automatically inserted quotation prefixes ("> ") make it clear what is
your text and what is text quoted by you. Quotation and reply should be
delimited by an empty line to ease reading.
And how would a complete newbie know where to look or know anything about
that URL?


See Lasse's followup.
J(ava)Script implemented client-side *has* type conversion, both explicit
and implicit.

** Well, i would like to learn about how that can be done.
Any suggestions, since "int" or "integer" does not work?


That depends on what you are actually looking for. If it is just typing
values, forget about that in these loosely-typed languages. Any numeric
literal is of type `number' (form control values are string values, so if
you want to do calculation with them, explicit conversion to `number' is
wise).

If it is explicit type conversion, try the unary `+' for all types of
operands, parseInt(...) or parseFloat(...) for string-type operands.
Note that `+' is the most efficient way but not fully backwards compatible,
and that parseInt(...) recognizes prefixes as indicators for a number base
(`0x' for 16; `0' for 8 in some implementations ), so you should specify
the base as second operand if you want it to interpret the string in a
certain way. IIRC all of this is described in the FAQ.
... Oh well, apparently the latter. The first thing you have to
understand is that JavaScript is not Java. That is *beginner's
knowledge*, you know.

** Well, i *now* know that, but was not aware of the distinction earlier.
Incompetent? Well,concerning Java Script, absolutely *yes*, hence the
dumb questions.


Read it from my fingertips: *There* *is* *no* "*Java* *Script*"!
Would such a thing help me?


If you would develop using a language that implements it, such as
Microsoft JScript.NET (AFAIK server-side only), it certainly would.


** Only interested i client side - *unless* - you know that it would be
easier to do a server side implimentation and can tell me how i get
someone's server to do whatever tricks are needed...


That depends on what you are actually looking for. There are image maps
that do not need client-side scripting, and submit the pointer coordinates
relative to the image position to the server; that information could be
evaluated with a server-side script. If you don't mean images, server-side
script cannot be of help obtaining that information (but maybe processing
it).
PointedEars
Apr 1 '06 #22
Robert Baer wrote:
Thomas 'PointedEars' Lahn wrote:
Robert Baer wrote:
It seems i am using Java Script, [...]
Yes, it only seems to be so. There is no "Java Script".
See my other followup.
[...]


Well, i am using some kind of Java code of some sort...


Java is off topic here.

BTW: Signatures are not to be quoted, unless there is an explicit reference
in the reply.
And you mentioned Java Script 2.0
,-[news:19******** ********@Pointe dEars.de]
|
| Not quite true. There is an `int' type, and variables can be strictly
| typed, in JavaScript 2.0. However, that is not implemented in a browser
^^^^^^^^^^
| yet.
so one might conclude that either it does exist or that someone is a
liar somewhere...


It does not, and you are.
Score adjusted

PointedEars
Apr 1 '06 #23
Robert Baer said the following on 4/1/2006 4:00 AM:
Thomas 'PointedEars' Lahn wrote:
Robert Baer wrote:

It seems i am using Java Script, [...]

Yes, it only seems to be so. There is no "Java Script".
See my other followup.
PointedEars

Well, i am using some kind of Java code of some sort...


You are using Javascript, not Java Script, and Thomas was being
childishly immature and pedantic about it.
And you mentioned Java Script 2.0 so one might conclude that either it
does exist or that someone is a liar somewhere...


It exists - in theory.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 1 '06 #24
Thomas 'PointedEars' Lahn said the following on 4/1/2006 7:28 AM:

<snip>
BTW: Signatures are not to be quoted,


Oh but you do not have a "signature" my boy. Do you actually need me to
post references to the numerous articles where you claim that you don't?

Or, is it an improperly delimited signature since it does not start with
dash dash space?

Make up your mind son, you can't have your cake and eat it too.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 1 '06 #25
VK

Robert Baer wrote:
Robert Baer wrote:
I used Google and found some references for integer in Java.
But "int" not only does not work, it also prevents reading X and Y
coordinates of the mouse.
OK, you'll be helped if you promise _stop_ calling JavaScript as "Java"
or "Java Script". You don't say "Linux" while talking about Windows, do
you? And you don't say that your browser is called "Inter Net
Ex-Plorer", do you?

So: the language you are trying to use is called JavaScript - 10
characters without space. The variant of this language implemented in
Internet Explorer is called JScript - 7 characters without space.
Collectively it is reffered as "JavaScript/JScript programming". To
save time and space it is often said just "script": "my script doesn't
work" etc. - if it is clear by context what your are talking about
JavaScript/JScript programming.

What i would like to do:
1) Get X and Y mouse coordinates into a variable that i can do real math
on.

You cannot do real math without using additional libraries and highly
resource expensive algorithms. In the normal circumstances you are
limited by machine math which may be identical, close or far away from
the real math - depending on values and operations. This is true for
JavaScript (10 chars no space - remember? ;-) as well as for Java, C,
C++, C# and any other language for PC (Personal Computer). See for
instance:-
<http://www.jibbering.c om/faq/#FAQ4_6> and
<http://www.jibbering.c om/faq/#FAQ4_7>

The code you posted is adjusted for NN4.x (1998-99) Empires raised and
falled since then :-)

Here is the HTML Strict compliant code for current generation of
browsers. Now if you tell what kind of math do you want to do with
mouse coords, one could suggest a proper way.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN"
"http://www.w3.org/TR/html401/strict.dtd">
<html>
<head>
<title>test 024</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<style type="text/css">
html {
margin: 0px 0px;
padding: 0px 0px}

body {
margin: 10px 10px;
padding: 0px 0px;
font: 1em Verdana, sans-serif;
color: #000000;
background-color: #FFFFFF}

form {
margin: 10px 10px;
padding: 5px 5px;
border: thin outset;
background-color: #EEEEEE}

form fieldset {
margin: 10px 10px;
padding: 10px 10px}

form fieldset legend {
margin: 0px 0px;
padding: 5px 5px;
cursor: default;
font-weight: bold}

form fieldset label {
float: left;
clear: left;
width: 20ex;
margin: 5px 0px;
padding: 0px 0px;
text-align: right}

form fieldset label:first-letter {
text-decoration: underline}

form fieldset input {
float: left;
width: 20ex;
margin: 5px 0px;
padding: auto auto;
font: 1em Verdana, sans-serif}

form fieldset button {
float: left;
margin: auto 5px;
padding: auto auto;
font: 1em Verdana, sans-serif}

form fieldset button:first-letter {
text-decoration: underline}
</style>

<script type="text/javascript">
function init() {
if ('undefined' == typeof mmX) {
mmX = document.forms['frm01'].elements['mmX'];
mmY = document.forms['frm01'].elements['mmY'];
}
W3 = ('undefined' != typeof document.body.a ddEventListener );
IE = ('undefined' != typeof document.body.a ttachEvent);
}

function start() {
if (W3) {
document.body.a ddEventListener ('mousemove',sh owCoords,true);
}
else if (IE) {
document.body.a ttachEvent('onm ousemove',showC oords);
}
else {
/*NOP*/
}
}

function stop() {
if (W3) {
document.body.r emoveEventListe ner('mousemove' ,showCoords,tru e);
}
else if (IE) {
document.body.d etachEvent('onm ousemove',showC oords);
}
else {
/*NOP*/
}
}

function showCoords(evt) {
var e = evt || event;
mmX.value = e.clientX;
mmY.value = e.clientY;
}

window.onload = init;
</script>

</head>

<body>
<!-- Pretty-print is adjusted to the "phantom nodes" issue -->
<form name="frm01" method="post" action=""
<fieldset><leg end>Mouse Coords</legend
<label for="mmX">X Coord:</label
<input type="text" name="mmX" id="mmX" accesskey="x">< br<label for="mmY">Y Coord:</label
<input type="text" name="mmY" id="mmY" accesskey="y"></fieldset
<fieldset><leg end>Controls</legend
<button type="button" accesskey="w" onClick="start( )">Watch</button
<button type="button" accesskey="u" onClick="stop() ">Unwatch</button></fieldset</form>


</body>
</html>

Apr 1 '06 #26
VK wrote:
Robert Baer wrote:

I used Google and found some references for integer in Java.
But "int" not only does not work, it also prevents reading X and Y
coordinate s of the mouse.


OK, you'll be helped if you promise _stop_ calling JavaScript as "Java"
or "Java Script". You don't say "Linux" while talking about Windows, do
you? And you don't say that your browser is called "Inter Net
Ex-Plorer", do you?


But I did like his calling it "Infuriatin g Exasperator"
Apr 3 '06 #27
VK

Tony wrote:
VK wrote:
And you don't say that your browser is called "Inter Net
Ex-Plorer", do you?


But I did like his calling it "Infuriatin g Exasperator"


In the context of the given topic the OP's source of frustration is not
clear at all. "Exasperato r" because it doesn't support NN4 event
handling mechanics? No one modern browser does it including Firefox.

Or because JScript doesn't have strict type declarations like int, long
or float? AFAIK it is common for all current implementations *in use* -
except JScript.NET (JScript 7.0).

Apr 4 '06 #28
Thomas 'PointedEars' Lahn wrote:
Robert Baer wrote:

Thomas 'PointedEars' Lahn wrote:
Robert Baer wrote:

Randy Webb wrote:

>Robert Baer said the following on 3/31/2006 6:28 AM:
>You had trouble because you were using, or attempting to use, a feature
>that is not part of the language. Not because of a feature that might
>be in a future release of the language unless you were reading a draft
>copy of JavaScript2.0 in which case you should have known it wasn't in
>use yet.

I had no idea that the "int" "feature" was not a part of the language.

AFAIK, it is merely not part of a language version that is implemented
_in Web browsers_. You could have RTFM first, and even if you had not,
you could have read and followed <URL:http://jibbering.com/faq/#FAQ4_43>
before you posted anything.


** ?RTFM? what is that?

Read The Fine/F***ing Manual. STFW (Search The Fine/F***ing Web).

Using any prefixes for your replies is unwanted. Attribution lines and
Automatically inserted quotation prefixes ("> ") make it clear what is
your text and what is text quoted by you. Quotation and reply should be
delimited by an empty line to ease reading.

And how would a complete newbie know where to look or know anything about
that URL?

See Lasse's followup.

J(ava)Scri pt implemented client-side *has* type conversion, both explicit
and implicit.


** Well, i would like to learn about how that can be done.
Any suggestions, since "int" or "integer" does not work?

That depends on what you are actually looking for. If it is just typing
values, forget about that in these loosely-typed languages. Any numeric
literal is of type `number' (form control values are string values, so if
you want to do calculation with them, explicit conversion to `number' is
wise).

If it is explicit type conversion, try the unary `+' for all types of
operands, parseInt(...) or parseFloat(...) for string-type operands.
Note that `+' is the most efficient way but not fully backwards compatible,
and that parseInt(...) recognizes prefixes as indicators for a number base
(`0x' for 16; `0' for 8 in some implementations ), so you should specify
the base as second operand if you want it to interpret the string in a
certain way. IIRC all of this is described in the FAQ.

... Oh well, apparently the latter. The first thing you have to
understand is that JavaScript is not Java. That is *beginner's
knowledge* , you know.


** Well, i *now* know that, but was not aware of the distinction earlier.
Incompetent? Well,concerning Java Script, absolutely *yes*, hence the
dumb questions.

Read it from my fingertips: *There* *is* *no* "*Java* *Script*"!

Would such a thing help me?

If you would develop using a language that implements it, such as
Microsoft JScript.NET (AFAIK server-side only), it certainly would.


** Only interested i client side - *unless* - you know that it would be
easier to do a server side implimentation and can tell me how i get
someone's server to do whatever tricks are needed...

That depends on what you are actually looking for. There are image maps
that do not need client-side scripting, and submit the pointer coordinates
relative to the image position to the server; that information could be
evaluated with a server-side script. If you don't mean images, server-side
script cannot be of help obtaining that information (but maybe processing
it).
PointedEars

I have tried HTML MAP and it is useful to a small extent; what i
found can only link to another web page OnMouseOver or the like - no
coordinates.
If you know of a syntax or such that will give coordinates, then i
would appreciate learning of such.
Apr 6 '06 #29
Randy Webb wrote:
Robert Baer said the following on 4/1/2006 4:00 AM:
Thomas 'PointedEars' Lahn wrote:
Robert Baer wrote:
It seems i am using Java Script, [...]

Yes, it only seems to be so. There is no "Java Script".
See my other followup.
PointedEars


Well, i am using some kind of Java code of some sort...

You are using Javascript, not Java Script, and Thomas was being
childishly immature and pedantic about it.
And you mentioned Java Script 2.0 so one might conclude that either
it does exist or that someone is a liar somewhere...

It exists - in theory.

Are you saying that there are *three* differing languages, "Java",
"JavaScript " and "Java Script"????
Or are there many similar-sounding languages depending which letter
is capitalized, where there is a space, etc?
Apr 6 '06 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
885
by: Elijah Bailey | last post by:
I have two char arrays of size k. I want to know which one is bigger (exactly like for instance I compare two ints/longs/etc.). What is the fastest way to do this? k <= 10 usually for my application. I tried bcmp / a loop for comparison, but it seems they are very slow compared to comparing longs...Any ideas? I tried splitting the array into longs and comparing, but then I face the high endian/low endian problem on some machines.
16
3382
by: aruna | last post by:
Given a set of integers, how to write a program in C to sort these set of integers using C, given the following conditions a. Do not use arrays b. Do not use any comparison function like if/then or switch-case c. you can use pointers only d. you cannot use any of the loops either.
15
6994
by: Paul Morrison | last post by:
Hi all, I need to come up with some differences between arrays in Java and C, I have searched Google and so far all I have found is the following: Arrays in Java are reference types with automatic allocation of memory. In C, arrays are groups of variables of the same type in adjacent memory. Allocation for dynamic arrays is handled by the programmer. This is an 8 mark question in an old exam paper, so I am assuming there are
3
7065
by: John Bend | last post by:
Hello. Can anyone please suggest some good tutorial links where Java Vectors and Arrays are explained and compared? I'm a proficient programmer but fairly new to Java. Whilst I understand arrays I don't fully understand Vectors and when to use them. Many thanks.
1
8703
by: Rob Griffiths | last post by:
Can anyone explain to me the difference between an element type and a component type? In the java literature, arrays are said to have component types, whereas collections from the Collections Framework are said to have an element type. http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html
17
3580
by: Robert Baer | last post by:
I used Google and found some references for integer in Java. But "int" not only does not work, it also prevents reading X and Y coordinates of the mouse. What i would like to do: 1) Get X and Y mouse coordinates into a variable that i can do real math on. So far, i can do math on the values "read" and that result goes into a "variable" that is useful *only* for display. If i try "int" in that math, the values are then zero for everything...
1
4672
by: susheela s | last post by:
Hi, Im doing a multiplication of two large integers which are store in arrays(such as 2345 is in array as 2 in a, 3 in a and so on)like this im storing integers in two arrays.The logic i have used is explained with code below, class large{ int no; //array is used to store the large number. Each digit of a the number is stored as an element.. // 123 is stored as no={1,2,3} public: large operator *(large& x){ // overload...
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7728
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.