Win a copy of Microservices Testing (Live Project) this week in the Spring forum!

Michael Comerford

+ Follow
since Jan 16, 2010
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Michael Comerford

Thanks Dennis, you're totally right. Once I sat down and actually went through the process I was attempting to automate step by step and wrote out dummy datasets etc. it made much more sense and I have now redesigned my code and it is now working for my purposes.

10 years ago
Hello, thanks for taking a look at my problem.

I'm implementing a merge sort algorithm in my code in order to sort data which is currently held in an arraylist of arraylists. The splits seem to be functioning fine (i've been doing a lot of System.out.print at every stage to make sure its doing what I think it's doing) However, when I get into the merge code I don't seem to be able to get it to run. I get stuck in an infinite loop and when I print what's going on to the console I get 0 over and over again from the output at line No. 15 in

Can anyone see any rookie errors? I've tried playing with how the loops are nested in case I missed a curly bracket in the right place.

Thanks :-)


So below are my two simple classes to implement the merge sort

and the second one....

10 years ago
Got it nailed thanks for your help guys!
11 years ago
No problem is here is the StataColumn class

11 years ago
Hi Rob, sure, here is the code I inserted before line 47 in the original.

11 years ago
Hi guys, thanks for the help narrowing this down

the console returns the folllowing when I included the System.out.prinf code

This object table is not null: true
This object table.get(i) is not null: true
This object tokens not null: true
This objects tokens[i] not null: trueException in thread "main" java.lang.NullPointerException
at StataColumn.add(
at CsvIn.main(

So tokens[i] is null?
tokens is a String array that takes it input from a Scanner that scans the csv file and splits it into elements and stores it in tokens[], so is it saying the i'th element is null?
Or am I missing something?

11 years ago
Hi guys, this problem has been frustrating me for hours, I've tried changing the code with little tweaks and commenting out bits to test it and dumping stuff to system.out to see what is happening along the way but I can't find a reason for this exception.

I'm building a csv parser (yes I know some already exist but my supervisor wants me to do this as part of a project) My code is included below

the test csv file I use looks like this:

"CaseId","Age","Name","Height [m]"

The exception occurs at line 47
all I'm doing in that section is differentiating between types, so storing the type of each column of data as either "s" for a string, "r" for a double, and "i" for an integer and then adding it to my 'table'(which is an arraylist of arraylists).

Any help greatly appreciated!

11 years ago
Wim thanks that was a really useful explanation, I fixed the problem and the code works now.

11 years ago
thanks for your help guys, I'm now trying to format my output so that it is in columns rather than rows.

The following code gives an IndexOutOfBoundsException at line 100 after printing the format I want for the first entry

I've had a look through the documentation for this exception and don't see how to resolve it, any clues?

11 years ago
Hi Hunter,

sorry I described the one using PrintWriter in my post and then posted the System.out one! here it is:

this just generates a blank file

11 years ago
Hi there,

Still pretty new at this but I've created an arraylist of arraylists as a 2d data structure for demographic data.

What I'm ultimately trying to do is write the data as csv

In the code below I can output the data to with System.out and it looks right in the console - it prints:


I thought I could just use the PrintWriter q I've created and use q.print( + ",") instead of the System.out line, when I try to run it I get a NoSuchElementException.

Any pointers?

11 years ago
Doh! Silly mistake, thanks Matthew!

11 years ago
Hi there,

I'm trying to create an arraylist of arraylists as a data structure to represent demographic data.

I've hit a brick wall already, when I try to add integers to one of my arraylists I get errors.

I'm using Eclipse and this program is for JavaSE 1.6

here's the code...

Eclipse tells me that there is:
Multiple markers at this line
- Syntax error on token(s), misplaced construct(s)
- Syntax error on token "id1", VariableDeclaratorId expected after this

at the lines that start caseid.add

Any help greatly appreciated!


11 years ago