using java variable from another file method in run of other file

user4735397

I have two files like this:

Client.java:

public class Client implements Runnable {
//code

   public void run() {
   //more code
       Crypt cls = new Crypt();
       cls.decrypt(request,key,type);
       //print "val" here.
   //more code
   }
}

And then the Crypt.java file which is like this:

public class Crypt{

    public static byte[] decrypt(byte[] val, byte[] key, int type)
    {

        //val assigned here
        // the following is used to assign it.
       val[length - len - 1] ^= key[8 + (((byte)(key[8 + b] + key[8 + a])) & 0xFF)];


      return val;
    }   

}

I need to be able to access the val variable in in the Client.java file again after it has run through the Crypt.java file.

I've tried cls.val and cls.decrypt.val but I don't know how to get it working.

Thanks for the help!

Razib

Your dycrypt() method in class Crypt is a static member of the Crypt class. So you don't need to create an instance of Crypt class in Client class like -

Crypt cls = new Crypt();
cls.decrypt(request,key,type);  

You can just call the decrypt() method using the class name and store the returns into a byte[] array -

byte[] vals = Crypt.decrypt(request, key, type); 

Then using a for loop/for-each loop you can print the vals array -

for(byte each : vals){
   System.out.println(each);
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

using java variable from another file method in run of other file

From Dev

How to run a java from another file?

From Dev

Using variable from another method in Java

From Dev

Using global instance of a class by another global variable in other file

From Dev

Node.js- Does setting a variable to a variable from another file also change that variable in the other file?

From Dev

using the variable "file" obtained from `for "file" in` and pass to another script fails

From Dev

How to call a method from another class, which is in another .java file?

From Dev

How to run method present in a file from the main method present in another file with mingw

From Dev

How to run method present in a file from the main method present in another file with mingw

From Dev

Run java file from other working path under Linux

From Dev

Run .js file from another .js file?

From Dev

how to run a file from another python file

From Dev

Java read from one file and write into another file using methods

From Dev

run a jar file from another Java copied in system

From Dev

Run only method from .py file using crontab

From Dev

Accessing a variable from another file

From Dev

Call a method using switch case from another C file?

From Dev

Objective C run 'private' method defined in one .mm file from another .mm file

From Dev

Use variable from one file to another file

From Dev

How can I read each line from a file into one variable for the last field, and another variable for the other fields?

From Dev

run a .sh file using java

From Dev

Run .txt file using java

From Dev

Run a jar file from a java file

From Dev

How to Run a Python file from Java using an Absolute Path?

From Dev

Run another binary/exe file using Lua?

From Dev

Using the system function to run another .cpp file

From Dev

how to add echo variable inside other variable from other file?

From Dev

Run a Program After Another in One Java File

From Dev

Setting a JTextField's content using text from another java file

Related Related

  1. 1

    using java variable from another file method in run of other file

  2. 2

    How to run a java from another file?

  3. 3

    Using variable from another method in Java

  4. 4

    Using global instance of a class by another global variable in other file

  5. 5

    Node.js- Does setting a variable to a variable from another file also change that variable in the other file?

  6. 6

    using the variable "file" obtained from `for "file" in` and pass to another script fails

  7. 7

    How to call a method from another class, which is in another .java file?

  8. 8

    How to run method present in a file from the main method present in another file with mingw

  9. 9

    How to run method present in a file from the main method present in another file with mingw

  10. 10

    Run java file from other working path under Linux

  11. 11

    Run .js file from another .js file?

  12. 12

    how to run a file from another python file

  13. 13

    Java read from one file and write into another file using methods

  14. 14

    run a jar file from another Java copied in system

  15. 15

    Run only method from .py file using crontab

  16. 16

    Accessing a variable from another file

  17. 17

    Call a method using switch case from another C file?

  18. 18

    Objective C run 'private' method defined in one .mm file from another .mm file

  19. 19

    Use variable from one file to another file

  20. 20

    How can I read each line from a file into one variable for the last field, and another variable for the other fields?

  21. 21

    run a .sh file using java

  22. 22

    Run .txt file using java

  23. 23

    Run a jar file from a java file

  24. 24

    How to Run a Python file from Java using an Absolute Path?

  25. 25

    Run another binary/exe file using Lua?

  26. 26

    Using the system function to run another .cpp file

  27. 27

    how to add echo variable inside other variable from other file?

  28. 28

    Run a Program After Another in One Java File

  29. 29

    Setting a JTextField's content using text from another java file

HotTag

Archive