Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #28262
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Problem with for |
| Date | Sun, 27 Apr 2014 14:04:25 -0400 |
| Organization | A noiseless patient Spider |
| Lines | 42 |
| Message-ID | <ljjgr9$143$1@dont-email.me> (permalink) |
| References | <e2c90ffd-b887-4257-8924-e1734d75de0a@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Sun, 27 Apr 2014 18:04:26 +0000 (UTC) |
| Injection-Info | mx05.eternal-september.org; posting-host="bd4e1cba8d8592bec5d5ed9e4537fbfd"; logging-data="1155"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18VgD6v9cb56ktRT8UWutof" |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 |
| In-Reply-To | <e2c90ffd-b887-4257-8924-e1734d75de0a@googlegroups.com> |
| Cancel-Lock | sha1:RF6i19IllG+06GbcKkR4FiuSdfI= |
| Xref | csiph.com comp.lang.java.programmer:28262 |
Show key headers only | View raw
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
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web