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

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top