Error when searching an array from another class' method... [message #1059871] |
Wed, 22 May 2013 04:21 |
Joseph Gill 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 + ".");
j++;
}
else {
System.out.println("nope");
}
}
}
CLASS 2:
search(searchString, colIndex)
public void search(String searchString, int colIndex) {
findMe FindMe = new findMe();
FindMe.searchArray(searchString, colIndex, numRows);
}
ERROR LOG:
made it to findMe
numRows = 3
I'm in here.
Exception in thread "main" java.lang.NullPointerException
at hey.RecordBook.findMe.searchArray(findMe.java:338)
at hey.RecordBook.searchMe.search(searchMe.java:118)
at hey.RecordBook.searchMe$2.widgetSelected(searchMe.java:92)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4136)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1458)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1481)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1271)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3982)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3621)
at hey.RecordBook.boss.main(boss.java:28)
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!
Thanks,
Joseph Gill
|
|
|
|
Powered by
FUDForum. Page generated in 0.04290 seconds