Vswe's Summer Courses | You're not logged in. Sign up or log in | Server time: | Donate
One can now see other persons' badge hunts. Simply head over to their profiles to access them.

Go back to course page

Coding and a cup of Java

An introduction course to programming

Compressing down loops

  • 2013-08-21 21:23:29
    I know in eclipse you can compress down a loop to see your code better, can you do this in Dr Java?
  • 2013-08-21 22:08:15
    I don't believe so
  • 2013-08-22 07:40:55
    Nope. Its a basic editor so a compress feature isn't really necessary. Although it might be helpful in some situations.
  • 2013-08-22 08:20:43
    Damn because I've got a lot of switch statements, cases, for loops, if statements and stuff like that and somewhere I've got an extra } and it's so frustrating because some of the cases keep coming up as orphaned!
  • 2013-08-22 12:41:49
    if youve an extra } it might be useful to look if you are not missing a {
  • 2013-08-22 12:46:31
    Oh yeah, didn't think of that, it just takes a while because there's so much code everywhere!
  • 2013-08-22 13:46:24
    was that the problem xD?, ive the same problem sometimes, but when you have it often, you will learn your mistakes xD
  • 2013-08-22 16:15:21
    It might have been the problem *looks down at feet* xD but i think the problem now with my assignment is that i have tried to make to many options for the user to input so there are switches and cases everywhere and I'm not even started! ;)
  • 2013-08-22 16:52:51
    Then you're probably doing it wrong I'm afraid.
  • 2013-08-22 16:53:39
    oh
  • 2013-08-22 16:54:29
    what i think i did was, i added on from what i got asked to do... dang it, looks like i'm starting again
  • 2013-08-22 16:58:44
    i tried to do to much, and im still a learning coder so i think i have to start again. it seems like the best thing to do
  • 2013-08-22 17:43:42
    A tip is to store the items in arrays and then refer to the index of the item the user asked for. That decreases the amount of switches you need and is generally much better.
  • 2013-08-22 18:59:45
    I did do that but I still have the mass amount of switches, but I think I was over complicating it by using multiple integers, when I should have been using a Boolean array
  • 2013-08-22 19:13:07
    And I also had trouble because you can't add new things to an array, you can only edit stuff. Is there a way around this?
  • 2013-08-22 19:51:29
    Try using ArrayList instead, i use it all the time if i want a variable size array.
  • 2013-08-22 20:30:06
    That's possible but not necessary at all. Most people solve the first assignment with normal arrays. You don't have to add more to the array afterwards. ArrayLists are being introduced in course 2.
  • 2013-08-22 20:41:18
    Oh okay, anyway thanks for all the help! I will get back to my assignment
  • 2013-08-23 20:58:15
    My advice is to add functionality piece by piece before writing the main flow control in separate methods, then you have higher chances to find a missing { or }
  • 2013-08-23 23:58:18
    for me, I always type the braces first before writing my code. Its hard to miss it this way. Also, it shouldn't be hard to spot the missing brace if you indent your code properly :)
  • 2013-08-25 15:21:20
    if you have a } or { missing, try clicking right next to the } and it will show where the corresponding { is
  • Log in or sign up to reply to this thread