for Loops.

Discussion in 'Plugin Development' started by Evangon, Oct 17, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Evangon

    Is it possible to do a for loop in Java? If you know Lua, you know what I mean. It's like for i=1, 10 do, and it just does i = 1+1 until it gets to ten.
    Example:
    for(i=1, 10) -- for every tick, add 1 to i=1 until i ='s 10

    It's a bit confusing, and also
    Is it possible to use getPositition().getX() + i?
     
  2. Offline

    thescreem

    Code:java
    1. for(int i = 0; i < 10; 1++){
    2. // code here
    3. }
    Will loop ten times. Adds 1 to i every loop, and stops when i is less than 10.

    I suggest learning Java a bit more...

    EDIT: Oops, fixed the for loop, such a stupid error :p
     
  3. Offline

    Evangon

    Sorry. I should look up more.
    Anyways, thanks.

    Edit: It's trying to convert a int to boolean, thus erroring.
    Any suggestions, or should I just go look this up?

    Edit: I got it. Just snagged the one from Oracle :p
     
  4. Offline

    Sagacious_Zed Bukkit Docs

    Your syntax is wrong, should be
    Code:
    for (int i = 0; i < 10; i++) { // inside loop here }
    actually it stops when i is not less than 10.... i.e. 10 or more including 10.
     
  5. Offline

    cjc343

    Might want to look over that for loop again... here's one that would stop when i is less than 10...

    for (int i = 20; i >= 10; i--) { }
     
  6. Offline

    King Rat

    Yes, that's extremely basic Java... Why ask here?
     
  7. Offline

    mindless728

    because people trying to make plugins should have a decent grasp on java first as not to waste our time on this when we could be helping people that are having Bukkit related programming questions
     
    Bone008 likes this.
  8. Sorry i thought this was another thread. (i agree)
     
  9. Offline

    mindless728

    ahhhhh ok, makes a lot more sense now
     
    tips48 likes this.
Thread Status:
Not open for further replies.

Share This Page