• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to modify the type of a data ?  RSS feed

 
jacques dusieur
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am trying to convert VBA code to Java and here is where I am stuck :

How, in Java, do I have to decalre my array of Double "data" in the method "produce" ?
How declare "data" in the method "read_file" to find it transformed then to pass it to the method "create" ?
How to change the type/do the "Redim" in the method "read_file" ?
Thanks for your help as I am returning to Java after more than 10 year stop...
 
Liutauras Vilda
Marshal
Posts: 4657
319
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Could you please describe in simple words the goal of the method?
Does it needs to return something, does it needs to take any inputs from outside?

That could look like pseudo code, which would be understandable by everyone. Thank you.

[edit] And welcome to the Ranch
 
Campbell Ritchie
Marshal
Posts: 55761
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again

I presume you once knew how to declare variables; you can remind yourself in the Java™ Tutorials.
 
jacques dusieur
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Thank you for your time. The vba code is actually already some pseudo code. In Java it would be something like :

I hope it is clearer.
Regards,
 
Liutauras Vilda
Marshal
Posts: 4657
319
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you're asking actually just a technical questions how it is done in Java. But keep in mind, that Java is quite different form VBA, and it won't let you do some crazy things as you could do with VBA.

jacques dusieur wrote:How, in Java, do I have to decalre my array of Double "data"

jacques dusieur wrote:How declare "data" in the method "read_file"

Honestly I don't feel it will help you much. Maybe it would help you better if you'd start reminding yourself about Java from here (<- link to click on).

As alternative, I think we could help you better if you'd describe what the method needs to do in details without using technical terminology, so we could adapt it to Java.
 
jacques dusieur
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. Unfortunately it is impossible to describe exactly what it does as it is a lot of statistics information treatment, but I have advanced a little in the skeleton comprehension. I know for sure that I will end up with a 2-dimensions array. I have now the following Java code :

I need to know how to define it correctly and how to pass it by reference (I would like to avoid returning my array, but instead have like an in/out parameter, which is called "pass a parameter by reference" I think) correctly because I still have these 2 issues :
At line PROBLEM 1, my array data seems to have only the first dimension initialised. Indeed, if toto is 100000 and titi 59,if I look up data[10][3] in debug mode, it says "<error(s)_during_the_evaluation>".
At line PROBLEM 2, my array data is null and has then lost the initialisation and the fill in done in readFile, I must be able to pass data by reference in order to retrieve it as it as been modified.
Thanks again in advance.
 
Campbell Ritchie
Marshal
Posts: 55761
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jacques dusieur wrote:. . . how to pass it by reference . . .
There is no such thing as pass by reference in Java®. Don't initialise the array to null. Get the create method to return an array
double[][] myArray = readFile(myFile);
Why are you passing the array as an output parameter to two methods?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!