Results 1 to 2 of 2
  1. #1
    bimtownboy is offline Member
    Join Date
    May 2013
    Posts
    2
    Rep Power
    0

    Default Shift Operators?

    Hi I am looking at the following code.I am really confused as to what the lines

    sb.append(Character.forDigit((char)((c >>> 4) & 0x0f), 16));
    sb.append(Character.forDigit((char)(c & 0x0f), 16));

    are doing.Could someone please Clarify.

    Thanks


    public static String escape(String string) {
    char c;
    String s = string.trim();
    StringBuffer sb = new StringBuffer();
    int length = s.length();
    for (int i = 0; i < length; i += 1) {
    c = s.charAt(i);
    if (c < ' ' || c == '+' || c == '%' || c == '=' || c == ';') {
    sb.append('%');
    sb.append(Character.forDigit((char)((c >>> 4) & 0x0f), 16));
    sb.append(Character.forDigit((char)(c & 0x0f), 16));
    } else {
    sb.append(c);
    }
    }
    return sb.toString();
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,422
    Rep Power
    20

    Default Re: Shift Operators?

    You didn't bother to return to the first thread you started: Question on Generics so why should we expect any better behavior this time round?

    Also, go through the Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming and edit your post accordingly.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. The Caesar Shift
    By BillyMayes in forum New To Java
    Replies: 4
    Last Post: 02-25-2013, 01:10 AM
  2. Multiply, or shift bits?
    By plm-pusik in forum New To Java
    Replies: 4
    Last Post: 03-15-2011, 11:08 PM
  3. where exactly bit shift operators are useful?
    By sandeepsai39 in forum New To Java
    Replies: 6
    Last Post: 09-08-2010, 12:58 PM
  4. Anyway to fix the lines so they dun shift?
    By PeterFeng in forum New To Java
    Replies: 0
    Last Post: 01-14-2009, 11:26 AM
  5. Run method on Ctrl+Shift+D
    By Echilon in forum AWT / Swing
    Replies: 1
    Last Post: 02-16-2008, 11:31 PM

Posting Permissions

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