Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

java string variable

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • java string variable

    I think what you are seeing is a pointer to a string object. Strings (in java) are not handled as variables, but as objects. So I believe what you are seeing is a reference to the object. Not the text contained within the string.

  • #2
    java string variable

    I thought my compile errors was due to this cast error, but now looking at a working example (Giuseppe Costagliola’s SQL2XLS) I now see that the string variables show up in debug as integer length 4 so the REAL question is why does the following example not compile: Class getlength receives a string and returns an integer
     D strieng S O CLASS(*JAVA:'java.lang.String') D num S 10I 0 D lotsChar S 3000A D makestring PR O ExtProc(*JAVA D :'java.lang.String' D :*CONSTRUCTOR) D bytes 3000A CONST VARYING D getlength PR O ExtProc(*JAVA D :'OneParm' D :'getLength') D CLASS(*JAVA:'java.lang.Integer') D STATIC D charVar O CLASS(*JAVA:'java.lang.String') D CONST C eval lotsChar = ‘count the chars in this string’ C eval strieng = makestring(lotsChar) C eval num = getlength(strieng) C Seton LR 
    Compile error against the getlength(strieng) function line RNF7416 30 1 The types of the right and left hand side do not match in the EVAL operation. Trevor

    Comment


    • #3
      java string variable

      My java is pretty weak, but it looks like you have getlength defined to return an object (CLASS(*JAVA:'java.lang.Integer')) not a variable. I think that line should be defined as an integer 10I 0, just like num.

      Comment


      • #4
        java string variable

        What are OneParm and getLength? Just prototype the String.length() method and it returns a 10i0 integer. Chris

        Comment


        • #5
          java string variable

          Chris, The purpose of my question is to figure out the syntax for defining input parameter definitions and returned variables for home grown classes. What is it about my code that makes the compiler barf. The book hasn't helped. Trevor
           public class HomeGrown { public static int whocares(String args[]) { } 

          Comment


          • #6
            java string variable

            I would guess that the getLength method returns an 'int' which is 10i0 in RPG, and not an Integer class. Change your prototype. Chris

            Comment


            • #7
              java string variable

              thanks Ken and Chris, changing the return parm to 10I0 got it to compile. And the execution error was a mismatch on the method name. Trevor That took almost two full days to decipher.

              Comment


              • #8
                java string variable

                From the book WebSphere® Development Studio: ILE RPG Programmer’s Guide Version 5 SC09-2507-04 Page 167 there is an example for calling a class and passing a string as a parameter.
                 The definition for the string is: * Define a field to store the String object we wish to trim * D str S O CLASS(*JAVA:’java.lang.String’) 
                When I compile this code in a program and look at the variables in debug/DSPMODSRC the attributes for the "string" variable 'str' are listed as Integer length 4. ATTR str TYPE = INTEGER, LENGTH = 4 BYTES What am I missing? If this isn’t how to define a string variable, what is the definition. Trevor

                Comment

                Working...
                X