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);
3
  • 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. Commented Aug 23, 2014 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. Commented Aug 23, 2014 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 here Commented Aug 23, 2014 at 11:55

1 Answer 1

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};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.