• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Java Help Needed!!!

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.
Java doesn't have pointers; Java has references. Also, in his case he's not even referencing anything outside of the array, because numTimes is simply an integer, and the 1 he's adding to it isn't an offset resulting in the out-of-bounds reference; it's the charAt() method doing it.

whether you like it or not, java does have pointers. Java just hides it from you. so you never have to use it. Proof, think of a Linked List Array, you have to have pointers to do it, or else you cannot go to the next element in the array.
 
Originally posted by: Gibson486
Java doesn't have pointers; Java has references. Also, in his case he's not even referencing anything outside of the array, because numTimes is simply an integer, and the 1 he's adding to it isn't an offset resulting in the out-of-bounds reference; it's the charAt() method doing it.

whether you like it or not, java does have pointers. Java just hides it from you. so you never have to use it. Proof, think of a Linked List Array, you have to have pointers to do it, or else you cannot go to the next element in the array.

They are called references, not pointers. Its an Object that references a spot in memory. Does the same thing as a pointer in C/C++, but is called a reference.
 
Originally posted by: Jzero
Originally posted by: Descartes
Originally posted by: AgaBooga
Thanks all! Its solved, I used Descartes' advice and worked from there although it took a little modifying. I would have used the other suggestions you guys gave but I was busy fixing it. Thanks again! 😀 :beer: 🙂

Sorry for being a direct pain in the arse by offering an indirect answer 🙂

You help him more by pointing him in the right direction than by just giving out the answer. :beer:

Descartes, this may sound odd from a 15 year old, but I'm kind of glad you did that. If you gave me the answer, sure, I'd get 10 more minutes of sleep, but I'd probably run into that problem again or something of the sort. Thanks again for suggestion, but I like that more than the final answer because anyone can go anyline with $5 in a paypal account and pay someone for it, but even less can do it on their own. 😀 🙂
 
Originally posted by: Gibson486
Java doesn't have pointers; Java has references. Also, in his case he's not even referencing anything outside of the array, because numTimes is simply an integer, and the 1 he's adding to it isn't an offset resulting in the out-of-bounds reference; it's the charAt() method doing it.

whether you like it or not, java does have pointers. Java just hides it from you. so you never have to use it. Proof, think of a Linked List Array, you have to have pointers to do it, or else you cannot go to the next element in the array.

As MCrusty has said, the difference is largely in the nomenclature; however, it's still a very important distinction to make. A reference does not a pointer make, and just because a reference decomposes into a memory address without a single level of indirection doesn't mean it's analogous to a pointer in languages that employ them natively (C, C++, C#). Can you do pointer arithmetic with a reference?

Foo f[] = new Foo[2];
f[0] = new Foo("1");
f[1] = new Foo("2");
Foo p = f; // nope
Foo p = f[0]; // ok
p++; // nope

I'm not trying to be pedantic, but you have to call things for what they are.
 
Originally posted by: AgaBooga
Originally posted by: Jzero
Originally posted by: Descartes
Originally posted by: AgaBooga
Thanks all! Its solved, I used Descartes' advice and worked from there although it took a little modifying. I would have used the other suggestions you guys gave but I was busy fixing it. Thanks again! 😀 :beer: 🙂

Sorry for being a direct pain in the arse by offering an indirect answer 🙂

You help him more by pointing him in the right direction than by just giving out the answer. :beer:

Descartes, this may sound odd from a 15 year old, but I'm kind of glad you did that. If you gave me the answer, sure, I'd get 10 more minutes of sleep, but I'd probably run into that problem again or something of the sort. Thanks again for suggestion, but I like that more than the final answer because anyone can go anyline with $5 in a paypal account and pay someone for it, but even less can do it on their own. 😀 🙂

The answers are always in the questions. Your knowledge will always be better served if you strive to know how the answers were derived. This applies in any discipline of course.

Taking Java in school at 15? Nice 😀
 
Originally posted by: Jzero
Originally posted by: Descartes
Originally posted by: AgaBooga
Thanks all! Its solved, I used Descartes' advice and worked from there although it took a little modifying. I would have used the other suggestions you guys gave but I was busy fixing it. Thanks again! 😀 :beer: 🙂

Sorry for being a direct pain in the arse by offering an indirect answer 🙂

You help him more by pointing him in the right direction than by just giving out the answer. :beer:

Agreed.
 
Back
Top