0

I have an algorithm written in Delphi and ask me to convert that to java equivalent.

It has a line of code that I can't understand, could anyone help me convert this line of code to java ?!

const list: array [1..37] of byte=(9,7,5,3,1,2,4,6,8,4,7,3,9,1,6,5,1,6,7,2,3,6,5,3,8,9,2,1,7,4,2,3,1,9,7,6,8);
mjn
  • 36,362
  • 28
  • 176
  • 378
m.sharifi
  • 11
  • 4
  • 1
    Err, and what have you tried ? I bet that if you'd Google for how to construct array in Java you would find the answer. This sounds like a homework of a lazy student. – TLama Aug 23 '14 at 11:18
  • 1
    If you don't understand that trivial line of pascal you need to stop and do some learning. You won't be able to understand the rest of the code either. – David Heffernan Aug 23 '14 at 11:32
  • @TLama @david-heffernan because of my bad english i coudn't explain my main problem, i am programming for more than 3 years in c++ c# and java. that algorithm does encode some data and has a block of code that convert some integer and string value to byte array and i think this line of code do that work , i was wrong , i found a solution [link](http://stackoverflow.com/a/19252022/3263370) `here` – m.sharifi Aug 23 '14 at 11:55

1 Answers1

1

First you will need to import Collection framework by declaring import java.util.*;

    byte data [] = {9,7,5,3,1,2,4,6,8,4,7,3,9,1,6,5,1,6,7,2,3,6,5,3,8,9,2,1,7,4,2,3,1,9,7,6,8};
    List<byte[]> list = new ArrayList<byte[]>(Arrays.asList(data));

    // outputting your data
    for(byte [] arrayOfByte : list){
    for( byte element : arrayOfByte){
    System.out.println(element);
    }
   }

If you don't want to use collection Framework then , simply :

    byte list [] = {9,7,5,3,1,2,4,6,8,4,7,3,9,1,6,5,1,6,7,2,3,6,5,3,8,9,2,1,7,4,2,3,1,9,7,6,8};
Fevly Pallar
  • 3,059
  • 2
  • 15
  • 19