Problem with for


V

Venom Lust

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?
 
Ad

Advertisements

V

Venom Lust

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
 
Ad

Advertisements

R

Roedy Green

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?
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top