Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #28261 > unrolled thread
| Started by | Venom Lust <lucas__bertollo@hotmail.com> |
|---|---|
| First post | 2014-04-27 10:55 -0700 |
| Last post | 2014-04-27 16:22 -0700 |
| Articles | 10 — 5 participants |
Back to article view | Back to comp.lang.java.programmer
Problem with for Venom Lust <lucas__bertollo@hotmail.com> - 2014-04-27 10:55 -0700
Re: Problem with for Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-04-27 14:04 -0400
Re: Problem with for lipska the kat <lipskathekat@example.com> - 2014-04-27 20:07 +0100
Re: Problem with for leif.roar@invalid.com (Leif Roar Moldskred) - 2014-04-27 15:56 -0500
Re: Problem with for lipska the kat <lipskathekat@example.com> - 2014-04-27 19:15 +0100
Re: Problem with for Venom Lust <lucas__bertollo@hotmail.com> - 2014-04-27 11:29 -0700
Re: Problem with for Venom Lust <lucas__bertollo@hotmail.com> - 2014-04-27 11:31 -0700
Re: Problem with for Venom Lust <lucas__bertollo@hotmail.com> - 2014-04-27 11:34 -0700
Re: Problem with for Venom Lust <lucas__bertollo@hotmail.com> - 2014-04-27 11:17 -0700
Re: Problem with for Roedy Green <see_website@mindprod.com.invalid> - 2014-04-27 16:22 -0700
| From | Venom Lust <lucas__bertollo@hotmail.com> |
|---|---|
| Date | 2014-04-27 10:55 -0700 |
| Subject | Problem with for |
| Message-ID | <e2c90ffd-b887-4257-8924-e1734d75de0a@googlegroups.com> |
public void writeText(String text)
{
char tmpchar;
int a = text.length();
for(int i = 0 ; i < text.length();i++);
{
jTextArea1.setText(jTextArea1.getText() + text.charAt(i));
try {
Thread.sleep(500);
} catch (InterruptedException ex) {
Logger.getLogger(IJFMain.class.getName()).log(Level.SEVERE, null, ex);
}
}
it says at text.charAt(i) that i doesnt exists and at for it says something like supress warning empty statement.
anyone knows whats happening?
[toc] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2014-04-27 14:04 -0400 |
| Message-ID | <ljjgr9$143$1@dont-email.me> |
| In reply to | #28261 |
On 4/27/2014 1:55 PM, Venom Lust wrote:
> public void writeText(String text)
> {
> char tmpchar;
> int a = text.length();
> for(int i = 0 ; i < text.length();i++);
The `for' statement executes its subordinate statement multiple
(usually) times. That subordinate statement is usually a {}-enclosed
block, but can be a simple statement. What you've written is a `for'
whose subordinate statement is just `;', the empty statement. So,
your code will execute `;' once for each `i' value, then forget all
about `i' and move ahead to the statement after the `for' ...
> {
> jTextArea1.setText(jTextArea1.getText() + text.charAt(i));
> try {
> Thread.sleep(500);
> } catch (InterruptedException ex) {
> Logger.getLogger(IJFMain.class.getName()).log(Level.SEVERE, null, ex);
> }
> }
... which happens to be a {}-enclosed block. But this block has nothing
to do with the `for', and is just a stand-alone bunch of code. The code
refers to a variable named `i', but there's no such variable -- there
once was an `i' that was part of the `for', but the `for' is long gone.
>
> it says at text.charAt(i) that i doesnt exists and at for it says something like supress warning empty statement.
>
> anyone knows whats happening?
Two things are happening. One, you don't know how to make a good
problem report: When you're puzzled by an error message, *quote* the
message and don't report "it says something like."
Two, you've got a semicolon that you don't want.
--
Eric Sosman
esosman@comcast-dot-net.invalid
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <lipskathekat@example.com> |
|---|---|
| Date | 2014-04-27 20:07 +0100 |
| Message-ID | <EJGdnY5l3d3KyMDOnZ2dnUVZ8iWdnZ2d@bt.com> |
| In reply to | #28262 |
On 27/04/14 19:04, Eric Sosman wrote: > On 4/27/2014 1:55 PM, Venom Lust wrote: >> public void writeText(String text) <snip> > Two things are happening. One, you don't know how to make a good > problem report: When you're puzzled by an error message, *quote* the > message and don't report "it says something like." WTF is wrong with you? Why do you *insist* on being such an arrogant pompous ass. Why don't you just give a simple, clear answer. Why The Fuck do you repeatedly insult and abuse people who's first language is not English? You really are a complete asshat aren't you. Sorry and all that but it really pisses me of when you and your cronies turn on people the way you do. You don't do it in c.l.c because you know you'd get short shrift from genuinely helpful and knowledgeable people. So why do you behave like that here? Jeez. -- lipska the kat - treacherous feline. Proudly nominated for IPOTY 2014 - LIGAF GNU/Linux user #560883 - linuxcounter.net
[toc] | [prev] | [next] | [standalone]
| From | leif.roar@invalid.com (Leif Roar Moldskred) |
|---|---|
| Date | 2014-04-27 15:56 -0500 |
| Message-ID | <0cSdne-uM-id8sDOnZ2dnUVZ8midnZ2d@giganews.com> |
| In reply to | #28269 |
lipska the kat <lipskathekat@example.com> wrote: > > WTF is wrong with you? > > Why do you *insist* on being such an arrogant pompous ass. Oh, give it a rest. Your pet, one-man crusade is, by far, the most arrogant and pompous behaviour that occurs in this newsgroup. -- Leif Roar Moldskred
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <lipskathekat@example.com> |
|---|---|
| Date | 2014-04-27 19:15 +0100 |
| Message-ID | <oOydnVECnqa01MDOnZ2dnUVZ7qKdnZ2d@bt.com> |
| In reply to | #28261 |
On 27/04/14 18:55, Venom Lust wrote:
> public void writeText(String text)
> {
> char tmpchar;
> int a = text.length();
> for(int i = 0 ; i < text.length();i++);
> {
> jTextArea1.setText(jTextArea1.getText() + text.charAt(i));
> try {
> Thread.sleep(500);
> } catch (InterruptedException ex) {
> Logger.getLogger(IJFMain.class.getName()).log(Level.SEVERE, null, ex);
> }
> }
>
>
> it says at text.charAt(i) that i doesnt exists and at for it says something like supress warning empty statement.
>
> anyone knows whats happening?
Try removing the ; at the end of the line
for(int i = 0 ; i < text.length();i++); <---- remove this semi-colon
--
lipska the kat - treacherous feline.
Proudly nominated for IPOTY 2014 - LIGAF
GNU/Linux user #560883 - linuxcounter.net
[toc] | [prev] | [next] | [standalone]
| From | Venom Lust <lucas__bertollo@hotmail.com> |
|---|---|
| Date | 2014-04-27 11:29 -0700 |
| Message-ID | <78d8221d-8851-4f54-a10a-4dd75c6cc733@googlegroups.com> |
| In reply to | #28264 |
Thanks lipska
[toc] | [prev] | [next] | [standalone]
| From | Venom Lust <lucas__bertollo@hotmail.com> |
|---|---|
| Date | 2014-04-27 11:31 -0700 |
| Message-ID | <a7adddc7-c984-4fdf-b29a-f80f7704273e@googlegroups.com> |
| In reply to | #28264 |
Thanks Lipska
[toc] | [prev] | [next] | [standalone]
| From | Venom Lust <lucas__bertollo@hotmail.com> |
|---|---|
| Date | 2014-04-27 11:34 -0700 |
| Message-ID | <64f46cd9-f308-4b13-acf6-f58e0614be4a@googlegroups.com> |
| In reply to | #28264 |
Thanks Lipska
[toc] | [prev] | [next] | [standalone]
| From | Venom Lust <lucas__bertollo@hotmail.com> |
|---|---|
| Date | 2014-04-27 11:17 -0700 |
| Message-ID | <38a75bfd-6f44-4a46-9b3d-c1cb758c8f43@googlegroups.com> |
| In reply to | #28261 |
First you don't need to humble my post, that's a great welcome. i`m in hurry, now i saw that ; in front of the for and i know there's variables that i didn't use but i don't know how to edit. Thanks anyways
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2014-04-27 16:22 -0700 |
| Message-ID | <i24rl9dbig18mq2hr0lr0ln7jn6khdcm5j@4ax.com> |
| In reply to | #28261 |
On Sun, 27 Apr 2014 10:55:00 -0700 (PDT), Venom Lust <lucas__bertollo@hotmail.com> wrote, quoted or indirectly quoted someone who said : > for(int i = 0 ; i < text.length();i++); Have a look at the standard loop patterns in http://mindprod.com/jgloss/javacheat.html#LOOPS _for_ is tricky. Every one of the semicolons has to be just so. Often the compiler does not warn you in an intelligible way if you misplace them. One of my favourite errors is to put a ; after the ++. Normally in Java ; is a terminator not a separator. Couple thoughts. _a_ is not a very good name for a length variable. Why did you compute it then never use it? -- Roedy Green Canadian Mind Products http://mindprod.com Computers are like Old Testament gods; lots of rules and no mercy. ~ Joseph Campbell (born: 1904-03-26 died: 1987-10-31 at age: 83)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web