1 Replies - 222 Views - Last Post: 20 December 2014 - 12:25 AM Rate Topic: -----

#1 zeus747  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 7
  • Joined: 17-December 14

Why am i getting this error when i createa for loop

Posted 20 December 2014 - 12:11 AM

this is my code

public class Dice extends Die {
    
    
    Die d1 = new  Die();
    Die d2 = new  Die();
    Die d3 = new  Die();
    Die d4 = new  Die();
    Die d5 = new  Die();
    Die d6 = new  Die();

    Die[] da = {d1,d2,d3,d4,d5,d6};
        
    Random  r = new Random();
Die[] ra = new Die[5];

    for(int k=0;k < 5 ;i++)
    {
        System.out.println(k);
    }
    
    public Die[]  roll()
    {
        return null;
    }
}



i am using netbeans 8.0.1 when i try to create a for loop i get this error this syntax is correct right ?

Is This A Good Question/Topic? 0
  • +

Replies To: Why am i getting this error when i createa for loop

#2 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 8275
  • View blog
  • Posts: 14,270
  • Joined: 19-March 11

Re: Why am i getting this error when i createa for loop

Posted 20 December 2014 - 12:25 AM

It's a good idea to post the error that you're running into, so people can have an idea of what problem you're trying to solve.

In this case, one problem sort of stands out, though:

for(int k=0;k < 5 ;i++)




Since you're testing on k and incrementing i, this will loop forever. If the error is "stack depth limit exceeded" or something of that sort, then this is the problem. Increment k instead of i.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1