Null pointer exception when using an array in type

thedesolatesoul

Expert
Licensed User
Longtime User
I am probably doing something wrong here (like not initialising the array) or something which I cannot pin point yet.

I have:

Type TouchCoordType (x As Int,y As Int)
Type PeopleType ( _
FollowPath(200) As TouchCoordType, _
Dim People As PeopleType

Then this line throws me an exception:
Msgbox (people.FollowPath(0).x,"Title")

Java is not happy :eek:
 

kickaha

Well-Known Member
Licensed User
Longtime User
I am probably doing something wrong here (like not initialising the array) or something which I cannot pin point yet.

I have:

Type TouchCoordType (x As Int,y As Int)
Type PeopleType ( _
FollowPath(200) As TouchCoordType, _
Dim People As PeopleType

Then this line throws me an exception:
Msgbox (people.FollowPath(0).x,"Title")

Java is not happy :eek:

Are you missing a line or close bracket there. Try
B4X:
Type TouchCoordType (x As Int,y As Int)
Type PeopleType ( _
FollowPath(200) As TouchCoordType)
Dim People As PeopleType 
people.Initialize
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
You should first call People.Initialize.
Calling Initialize is required when there is a non-primitive variable type inside the declared type.

Ah...I was unaware of that. Thanks!

Are you missing a line or close bracket there. Try

I had a bracket there. Just missed it out when doing selective copy.:)
 
Upvote 0
Top