Nandosta
Member
When building a simple List I intended to use for testing I got following error:
java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [Ljava.lang.String;
The strange thing is that when I step through the For .. Next loop code line by line, the error does not show.
java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [Ljava.lang.String;
The strange thing is that when I step through the For .. Next loop code line by line, the error does not show.
B4J:
'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
Sub Process_Globals
End Sub
Sub AppStart (Args() As String)
Private Fruit_List As List
Private Fruit_Array(2) As String
Fruit_List.Initialize
Fruit_List.Add(Array("banana", "1.49", "kg"))
Fruit_List.Add(Array("lemon", "1.69", "pc"))
Fruit_List.Add(Array("apple", "2.29", "kg"))
For i = 0 To (Fruit_List.Size - 1)
Fruit_Array = Fruit_List.Get(i)
Log("(" & i & ") = " & Fruit_Array(0) & " " & Fruit_Array(1) & " " & Fruit_Array(2))
Next
End Sub
Error log:
Waiting for debugger to connect...
Program started.
Error occurred on line: 22 (Main)
java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [Ljava.lang.String; ([Ljava.lang.Object; and [Ljava.lang.String; are in module java.base of loader 'bootstrap')
at b4j.example.main._appstart(main.java:90)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:95)
at b4j.example.main.main(main.java:29)
Program terminated (StartMessageLoop was not called).