mazeingmazerules
Member
+8|6724|Canada
For loop you queer.

Loops in Java are very useful for those who want to implement things that repeat them self.  For instance, we would not use a loop in this situation:

Code:

badExample += 1;
badExample += 1;
Alright, I have to admit this is a bad example but hey.  Anyways, lets say that we wanted this integer to grow 10 times.  Now this is where the loop comes in handy.  Every loop must begin with something like the following.

By the way, this is the for loop.

Code:

for (int i = 0; i < 10; i++) {
Please note that the number 10 can be changed to match certain situations.  Anyhow, this basically means for the loop, it will then set the integer to 0 and then it'll count to 10 because of i++.  Hopefully, you understood what that meant. 

Now, here is one last example to clear most things up with you.  This is a better example then the other one because you will actually see this in some servers.

Code:

        
        client.stream.writeString("");
        client.stream.writeString("");
        client.stream.writeString("");
        client.stream.writeString("");
        client.stream.writeString("");
        client.stream.writeString("");
        client.stream.writeString("");
        client.stream.writeString("");
What this does is that it replaces the line of text with nothing.  But, it's pointless to write out the same thing over again.  So what you would use is a loop to make things smaller and easier to edit.

Code:

for (int i = 0; i < 8; i++) {
        client.stream.writeString("");
}
What this does it that it'll basically replace the line of text 8 times with nothing given it the same effect as the code a bit above.
Macbeth
Banned
+2,444|5831

I Don't Know What Any Of This Means But It Looks Long And Complicated And I Like It.
mazeingmazerules
Member
+8|6724|Canada
Java is my hobby. <3
Macbeth
Banned
+2,444|5831

mazeingmazerules wrote:

Java is my hobby. <3
Cool. I don't know any of this but I guess it's a good skill.
jsnipy
...
+3,277|6768|...

great 101 stuff, probably lost on folks here.
Kmar
Truth is my Bitch
+5,695|6846|132 and Bush

http://sfbay.craigslist.org/sfc/eng/1246353621.html
An employment opportunity for you.
Xbone Stormsurgezz
Computer_Guy
Member
+54|6943
dont remind me any of that stuff, i dont want to ever see it again. i already passed the class with an A and now they want me to take C++
Rod Foxx
Warblgarbl
+78|6229|Perth, Australia
Java is dead easy to code in. C++ on the other hand is "fun".

I'm currently learning C# for a contract job that i've picked up. Looks pretty simple so far.

I still can't figure out what the point of this topic was though

Board footer

Privacy Policy - © 2024 Jeff Minard