dfgdfgddsdfgsdvcxvbcvbcxvb
Printable View
dfgdfgddsdfgsdvcxvbcvbcxvb
in Search.java is probably empty hence nullpointer with data.JourneyArray[position]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.javaCode:...
public static BusData getData() {
return data;
}
Code://BusData data=new BusData();
BusData data = new Main().getData();
Which line is line 57?
ozzyman i tried what you said but it didnt work :(
kjkrum heres line
Code:System.out.println(search.showTime(0,1));
So do I add this to the Main.java:
and then add this in Search.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 errorCode: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.
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;
}
}