SpAm101's Profile User Rating: -----

Reputation: 11 Tradesman
Group:
Active Members
Active Posts:
54 (0.07 per day)
Joined:
28-November 12
Profile Views:
2,020
Last Active:
User is offline May 09 2013 07:40 AM
Currently:
Offline

Previous Fields

Country:
GB
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
AMD
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
0
Icon   SpAm101 has not set their status

Posts I've Made

  1. In Topic: Beginner Java Array Insertion Sort

    Posted 28 Mar 2013

    Hi again mushkyn

    The program is correct, you just have a semicolon where it shouldn't be:

    Make this:

    for(i=1; i<n; i++);
    


    this:

    for(i=1; i<n; i++)
    


    What was happening is the loop was completing by executing nothing, it was the same as doing this:

    for(i=1; i<n; i++)
    {
    }
    insert(x, i); 
    


    The loop continues until i is no longer less than n. This logically means i would be equal to n when the loop finishes. Normally this doesn't matter because the int used is declared only for the duration of the loop, but in your case, because of the semi-colon, you were accidently using the final value of 5.
  2. In Topic: Beginner Java Array Insertion Sort

    Posted 28 Mar 2013

    View PostGungnir, on 28 March 2013 - 02:49 AM, said:

    There's a DEBUG perspective, but I've always found that switching between perspectives just serves to confuse me even more. It's not particularly useful in the first place. I prefer custom logs.

    The OP can use whichever method.


    Each to their own of course. I simply suggest the debugger because it generally lets you see the state of local variables at the time of execution.

    The OP sticks a breakpoint on all the lines that are significant and where it could error out and they can see the value of x and j before the line even executes.

    View Postmushkyn, on 28 March 2013 - 02:55 AM, said:

    it displays: "java.lang.ArrayIndexOutOfBoundsException: 5".


    Then it's as Gungnir quite correctly said. You've got an array of size 5, so the indexes available are 0,1,2,3,4

    5 doesn't exist.

    View Postmushkyn, on 28 March 2013 - 02:55 AM, said:

    I'm not sure about the debugging tool, I haven't really covered how to use that yet but if you still think it would help with this, I will look into it.


    I'm not familiar with BlueJ I'm afraid, but if you Google it, i'm sure they'll be some tutorials.
  3. In Topic: Beginner Java Array Insertion Sort

    Posted 28 Mar 2013

    Quote

    Whip up a quick debugger to check.


    Or preferably use the one already built into the IDE. If you're not using an IDE, then you should.

    If you're using netbeans, here's a quick tut on the debugging tool:

    http://www.cs.uga.ed...gerTutorial.htm

    You can Google for an eclipse one if you need.
  4. In Topic: Looping quirk

    Posted 18 Mar 2013

    Hi ngroebner

    Take a look at this SO thread:

    http://stackoverflow...e-after-nextxxx
  5. In Topic: Assignment question - deleting table row in servlet.

    Posted 15 Mar 2013

    Calling the doGet() method from doPost() is bad practice and goes against how HTTP works.

    You should response.sendRedirect instead to create a new GET request, which will call the doGet automatically.

My Information

Member Title:
D.I.C Head
Age:
23 years old
Birthday:
May 29, 1991
Gender:
Location:
Norfolk, England
Full Name:
Sam
Years Programming:
6
Programming Languages:
HTML, CSS, Java, PHP, C#, C++, Javascript, SQL

Contact Information

E-mail:
Click here to e-mail me

Friends

SpAm101 hasn't added any friends yet.

Comments

SpAm101 has no profile comments yet. Why not say hello?