Results 1 to 5 of 5
  1. #1
    fredfunk is offline Member
    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Default what this snippet will do?

    hello,
    im new to this, please help on this example what will be the output?

    byte[] arrayOfByte = { (byte) 0xe7, (byte) 0x0a, (byte) 0x3f, (byte) 0x16, (byte) 0xcc, (byte) 0x16, (byte) 0x0c, (byte) 0xaf, (byte) 0x3d, (byte) 0x00, (byte) 0xd3, (byte) 0x0b, (byte) 0x71, (byte) 0x93, (byte) 0xc8, (byte) 0xf7};
    int j = 0;
    String str = "";
    while (true)
    {
    if (j >= arrayOfByte.length)
    return str;
    str = str + Integer.toString(256 + (0xFF & arrayOfByte[j]), 16).substring(1); -can somebody explain what math happens here?
    j++;
    }

    what will be in the str in the end?
    many thanks

  2. #2
    arieltal is offline Member
    Join Date
    Sep 2012
    Posts
    34
    Rep Power
    0

    Default Re: what this snippet will do?

    my advice is to simply use System.out.println(str); and find out.
    as for the math itself, i will leave it to someone who knows. :)

  3. #3
    fredfunk is offline Member
    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Default Re: what this snippet will do?

    unfortunnaly i dont have java enviroment right now

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: what this snippet will do?

    Quote Originally Posted by fredfunk View Post
    unfortunnaly i dont have java enviroment right now
    Then you'll want to check this out when you are able to compile and run this yourself. This site is not supposed to be used as a substitute for your Java compiler and JVM.

  5. #5
    fredfunk is offline Member
    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Default Re: what this snippet will do?

    the forum's purpose is solved, thank you so much

Similar Threads

  1. Example Count From Array Snippet
    By Vinx in forum Reviews / Advertising
    Replies: 1
    Last Post: 05-18-2012, 05:22 AM
  2. Code snippet pls?
    By Srinivas0615 in forum New To Java
    Replies: 1
    Last Post: 07-29-2011, 10:32 PM
  3. what are the problems of the snippet
    By QkrspCmptPop in forum Threads and Synchronization
    Replies: 1
    Last Post: 01-26-2010, 01:21 AM
  4. J2ME MIDlet snippet
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-21-2007, 11:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •