B4J Code Snippet Initializing JavaObject

Discussion in 'B4J Code Snippets' started by Daestrum, May 21, 2019.

  1. Daestrum

    Daestrum Well-Known Member Licensed User

    I often wished the following code was valid
    Code:
    Dim someVar as JavaObject = someVar.InitializeNewInstance("some.java.class",null)
    but alas, someVar doesn't exist on the right side until the dim statement is executed
    so we have to use
    Code:
    Dim someVar as JavaObject
    someVar.InitializeNewInstance(
    "some.java.class",null)
    but …..
    if you add this tiny method
    Code:
    Sub New(javaClass as String, Values() as Object) As JavaObject
    Dim Jo as JavaObject
    Return Jo.InitiallizeNewInstance(javaClass,values)
    End Sub
    Now you can have
    Code:
    Dim someVar As JavaObject = New("some.java.class",null)
     
    Last edited: May 21, 2019
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice