Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Error when searching an array from another class' method...(Error when searching an array from another class' method...)
Error when searching an array from another class' method... [message #1059871] Wed, 22 May 2013 04:21 Go to next message
Joseph Gill is currently offline Joseph GillFriend
Messages: 1
Registered: May 2013
Junior Member
So, I'm trying to search a String[][] named SearchableArray in a given column col. This array has a specified number of rows numRows. The program makes it to the println which reads "I'm in here", but the next line is what gives me all the errors.

The statement SearchableArray[row][col].contains(searchString) represents a boolean, thus it should work perfectly with the surrounding code.

The snippet from CLASS 2 is calling the code shown from CLASS 1 with the last line of code shown. Maybe this boils down to some lack of experience I have with passing things from a method in one class to another method in another class. Any advice is WELCOME!

CLASS 1 (Class FindMe):

public void searchArray(String searchString, int col, int numRows) {

System.out.println("made it to findMe");
FoundRowIndexes = new int[numRows];

j = 0;
System.out.println("numRows = " + numRows);
for(int row = 0; row<numRows; row++) {
System.out.println("I'm in here.");
if(SearchableArray[row][col].contains(searchString)) {
System.out.println("I'm in here too.");
FoundRowIndexes[j] = row;
System.out.println("Found " + searchString + " at row index " + row + " and column index "+ col + ".");
else {


search(searchString, colIndex)

public void search(String searchString, int colIndex) {
findMe FindMe = new findMe();
FindMe.searchArray(searchString, colIndex, numRows);


made it to findMe
numRows = 3
I'm in here.
Exception in thread "main" java.lang.NullPointerException
at hey.RecordBook.findMe.searchArray(
at hey.RecordBook.searchMe$2.widgetSelected(
at org.eclipse.swt.widgets.TypedListener.handleEvent(
at org.eclipse.swt.widgets.EventTable.sendEvent(
at org.eclipse.swt.widgets.Display.sendEvent(
at org.eclipse.swt.widgets.Widget.sendEvent(
at org.eclipse.swt.widgets.Widget.sendEvent(
at org.eclipse.swt.widgets.Widget.sendEvent(
at org.eclipse.swt.widgets.Widget.notifyListeners(
at org.eclipse.swt.widgets.Display.runDeferredEvents(
at org.eclipse.swt.widgets.Display.readAndDispatch(
at hey.RecordBook.boss.main(
2013-05-21 23:47:03.830 java[7210:903] *** __NSAutoreleaseNoPool(): Object 0x100167190 of class __NSCFDate autoreleased with no pool in place - just leaking
2013-05-21 23:47:03.833 java[7210:903] *** __NSAutoreleaseNoPool(): Object 0x10015a3e0 of class NSCFTimer autoreleased with no pool in place - just leaking

Again, any advice is WELCOME!


Joseph Gill
Re: Error when searching an array from another class' method... [message #1059998 is a reply to message #1059871] Wed, 22 May 2013 13:44 Go to previous message
David Wegener is currently offline David WegenerFriend
Messages: 1409
Registered: July 2009
Senior Member
First, this forum is for question related to using the Eclipse Java Development Tools. It isn't a general Java programming forum. You need to ask general Java questions on stack overflow or similar forum.

You haven't given enough context to answer your question. You don't show where SearchableArray is defined so anyone looking to help is left to guess what it is. You also don't show if this variable is initialized any place. My guess would be that this is an initialization problem. Java arrays aren't automatically initialized, you have to add all elements. If you don't initialize an array, you will get NullPointer exceptions.

Previous Topic:I want my perspective button bar back
Next Topic:IJavaProject without Eclipse Environment
Goto Forum:

Current Time: Wed Apr 25 12:59:09 GMT 2018

Powered by FUDForum. Page generated in 0.02174 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software