hub73 Active Member Licensed User Longtime User Oct 29, 2016 #1 Hello! Is it correct to declare an array inside an type like this : Type Type_playlist (Id As Int, Pk_num_playlist As Int, Music_file(100) As String, Music_title(100) As String) B4X: Dim Playlist(6) As Type_playlist For j=0 To 4 Playlist(0).Music_file(j) = "test.mp3" ' <--------- java.lang.NullPointerException here ! Next error occcured java.lang.NullPointerException ! Many thanks !
Hello! Is it correct to declare an array inside an type like this : Type Type_playlist (Id As Int, Pk_num_playlist As Int, Music_file(100) As String, Music_title(100) As String) B4X: Dim Playlist(6) As Type_playlist For j=0 To 4 Playlist(0).Music_file(j) = "test.mp3" ' <--------- java.lang.NullPointerException here ! Next error occcured java.lang.NullPointerException ! Many thanks !
DonManfred Expert Licensed User Longtime User Oct 29, 2016 #2 You need to initialize the Type first... B4X: For j=0 To 5 Playlist(j).Initialize Playlist(j).Music_file(0) = "test.mp3" ' <--------- no Exception here :D Next Upvote 0
You need to initialize the Type first... B4X: For j=0 To 5 Playlist(j).Initialize Playlist(j).Music_file(0) = "test.mp3" ' <--------- no Exception here :D Next