I have this code:
if i try to compile have this error :
*** Service (starter) Create ***
** Service (starter) Start **
Error occurred on line: 86 (Main)
java.lang.ClassCastException: java.lang.Object[] cannot be cast to int[][]
at b4a.example.main._btnaggiornabanconote_click(main.java:428)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at b4a.example.main.initializeGlobals(main.java:320)
at b4a.example.main.afterFirstLayout(main.java:101)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
** Activity (main) Create, isFirst = true **
but if i change this sub adding a blank line it work :
I can't explain it
??????
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private numTagliBanconote As Int = 6
Private TagliBanconote() As Int
Private BanconoteDisponibili(10,3) As Int
Private d1 As EditText
Private d2 As EditText
Private d3 As EditText
Private d4 As EditText
Private d5 As EditText
Private d6 As EditText
Private n1 As EditText
Private n2 As EditText
Private n3 As EditText
Private n4 As EditText
Private n5 As EditText
Private n6 As EditText
d1.Initialize("")
d2.Initialize("")
d3.Initialize("")
d4.Initialize("")
d5.Initialize("")
d6.Initialize("")
n1.Initialize("")
n2.Initialize("")
n3.Initialize("")
n4.Initialize("")
n5.Initialize("")
n6.Initialize("")
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
d1.text ="20"
d2.text ="5"
d3.text ="2"
d4.text ="0"
d5.text ="0"
d6.text ="0"
n1.text ="5"
n2.text ="10"
n3.text ="20"
n4.text ="10"
n5.text ="50"
n6.text ="100"
btnAggiornaBanconote_Click
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnAggiornaBanconote_Click
TagliBanconote = Array As Int(n1.text, n2.text, n3.text, n4.text, n5.text, n6.text)
BanconoteDisponibili = Array (Array As Int(n6.text, d6.text,0,0), Array As Int(n5.text, d5.text,0,0), Array As Int(n4.text, d4.text,0,0), Array As Int(n3.text,d3.text,0,0), Array As Int(n2.text, d2.text,0,0), Array As Int(n1.text, d1.text,0,1))
End Sub
if i try to compile have this error :
*** Service (starter) Create ***
** Service (starter) Start **
Error occurred on line: 86 (Main)
java.lang.ClassCastException: java.lang.Object[] cannot be cast to int[][]
at b4a.example.main._btnaggiornabanconote_click(main.java:428)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at b4a.example.main.initializeGlobals(main.java:320)
at b4a.example.main.afterFirstLayout(main.java:101)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
** Activity (main) Create, isFirst = true **
but if i change this sub adding a blank line it work :
B4X:
Sub btnAggiornaBanconote_Click
TagliBanconote = Array As Int(n1.text, n2.text, n3.text, n4.text, n5.text, n6.text)
BanconoteDisponibili = Array (Array As Int(n6.text, d6.text,0,0), Array As Int(n5.text, d5.text,0,0), Array As Int(n4.text, d4.text,0,0), Array As Int(n3.text,d3.text,0,0), Array As Int(n2.text, d2.text,0,0), Array As Int(n1.text, d1.text,0,1))
End Sub
I can't explain it
??????
Last edited: