Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

loop error help

Thread view: 
sacha_schembri@yahoo.com - 24 Oct 2006 16:10 GMT
Hi im having trouble with this loop it stops at certain places but
never finiishes as it should

try {
BufferedWriter out = new BufferedWriter(new
FileWriter("file.txt",true));
for (int y = 0; y < stuobj1.stdrec.length;y++){
if (stuobj1.stdrec[1+y].equals(field1))
{y++;y++;y++;}
else
{System.out.println(y);
out.write(stuobj1.stdrec[y]);y++;
out.newLine();
out.write(stuobj1.stdrec[y]);y++;
out.newLine();
out.write(stuobj1.stdrec[y]);y++;
out.newLine();
out.write(stuobj1.stdrec[y]);
out.newLine();
out.close();
}}
} catch (IOException eee) {    }
Ingo R. Homann - 24 Oct 2006 16:18 GMT
Hi,

> Hi im having trouble with this loop it stops at certain places but
> never finiishes as it should

- What's the data-types (stuobj etc)?
- What's the data?
- What *does* the program do?
- What do you expect it to do?

We cannot say anything to your problem if you do not provide this
information! (Although I expect that you are able to solve your problem
if you try to answer my questions...)

Oh, some things can be said:
- In most cases, it is not a good idea to modify the counter-variable of
a for-loop within the body of the loop.
- Please format your code in a readable style!

Ciao,
Ingo
sacha_schembri@yahoo.com - 24 Oct 2006 16:48 GMT
Thanks anyway  i fixed it i put the try...catch within the loop instead
and worked like a charm, sorry for the un formatted code but im doing
my assignment for school and we have to work in textpad cant use an IDE
and when i copied it here my formatting got messed up


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.