Results 1 to 7 of 7
- 04-25-2011, 06:25 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 18
- Rep Power
- 0
-
in Search.java is probably empty hence nullpointer with data.JourneyArray[position]Java Code:BusData data=new BusData();
I think you need to add a method in Main.java to retrieve the field 'data' from other classes.
Main.java
Search.javaJava Code:... public static BusData getData() { return data; }
Java Code://BusData data=new BusData(); BusData data = new Main().getData();
- 04-25-2011, 06:58 PM #3
Which line is line 57?
- 04-25-2011, 07:12 PM #4
Member
- Join Date
- Apr 2011
- Posts
- 18
- Rep Power
- 0
ozzyman i tried what you said but it didnt work :(
kjkrum heres line
Java Code:System.out.println(search.showTime(0,1));
-
- 04-26-2011, 01:16 AM #6
Member
- Join Date
- Apr 2011
- Posts
- 18
- Rep Power
- 0
So do I add this to the Main.java:
and then add this in Search.java:Java Code:BusData datas; public Main() { datas=null; } public void setData(BusData datas) { this.datas=datas; } public BusData getData() { return datas; }
I tried that and i still have the same errorJava Code:BusData data = new Main().getData();
-
datas = null? no, you're supposed to run your whole method so that you fill up data with actual values.
Java Code:public class MyClass { private BusData data; MyClass() { main(); } public static void main() { data = new BusData(); for(int i=0; i<someObject.length; i++) { data += someObject[i].value(); } } public BusData getData() { return data; } }
Similar Threads
-
searching for a name in my 2d array and printing the info that is on its row
By ziongio in forum New To JavaReplies: 3Last Post: 03-15-2011, 12:24 PM -
searching char array with another char array for full word matches
By karunabdc in forum New To JavaReplies: 2Last Post: 03-08-2011, 06:20 AM -
Searching and comparing Array elements
By jmanswrd in forum New To JavaReplies: 5Last Post: 02-15-2011, 06:06 AM -
Sorting/Searching Objects with multiple types.
By gcampton in forum New To JavaReplies: 20Last Post: 10-21-2009, 11:58 PM -
Searching In a String Array - Problem
By DillMan in forum New To JavaReplies: 4Last Post: 12-07-2008, 09:12 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks