I'm converting a string into a character array in order to use the Arrays.sort() method on it. However, when I turn the array back into a string and try to print it out, it gives me a bunch of hexadecimal (I believe) instead of the actual string. In fact, I also get hexadecimal trying to print the sortedStringchar... why is this happening, why am I not getting the strings/character array printed in characters?     String originalString = &quot;HELLO&quot;;     char[] sortedStringChar = originalString.toCharArray();     Arrays.sort(sortedStringChar);     String sortedString = sortedStringChar.toString();     System.out.println(&quot;Sorted String ===== &quot; + sortedString);  Output of System.out.println:       Sorted String ===== [C@2d928643
872
In Java, arrays don't override toString(), so if you try to print one directly, you get the className + '@' + the hex of the  of the array, as defined by Object.toString():  int[] intArray = new int[] {1, 2, 3, 4, 5}; System.out.println(intArray);     // prints something like '[I@3343c8b3'   But usually, we'd actually want something more like [1, 2, 3, 4, 5]. What's the simplest way of doing that? Here are some example inputs and outputs:  // Array of primitives: int[] intArray = new int[] {1, 2, 3, 4, 5}; //output: [1, 2, 3, 4, 5]  // Array of object references: String[] strArray = new String[] {"John", "Mary", "Bob"}; //output: [John, Mary, Bob]
63970
Possible Duplicate:          I want to write a function that reverses the given string passed into it. But, I can not. If I supply the doReverse function (see code below) with a character array, my code works well.  I can't figure out why this does not work. I am able to access str[0] in doReverse, but I can't change any value of the array by using a char pointer. Any ideas?  void doReverse(char *str) {     str[0] = 'b'; }  void main(void) {     char *str = "abc";     doReverse(str);     puts(str); }   Update:  I know how to do write a reverse function by passing a character array to it:  void reverse1(char p[]) {     int i, temp, y;      for (i = 0, y = strlen(p); i &lt; y; ++i, --y) {         temp = p[y-1];         p[y-1] = p[i];         p[i] = temp;     } }   But, I want to write another version that gets a char pointer as a parameter.
4461
This prints 83  System.out.println(0123)   However this prints 123  System.out.println(123)   Why does it work that way?
113003
We are using the CString class throughout most of our code. However sometimes we need to convert to a char *. at the moment we have been doing this using variable.GetBuffer(0) and this seems to work ( this mainly happens when passing the Csting into a function where the function requires a char *). The function accepts this and we keep going.  However we have lately become worried about how this works, and whether there is a better way to do it.  The way i understand it to work is it passes a char pointer into the function that points at the first character in the CString and all works well.  I Guess we are just worried about memory leaks or any unforseen circumstances where this might not be a good idea.
19898
Is there an efficient method of converting an integer into the written numbers, for example:  string Written = IntegerToWritten(21);   would return "Twenty One".  Is there any way of doing this that doesn't involve a massive look-up table?
1314
I have a char in c#:  char foo = '2';   Now I want to get the 2 into an int.  I find that Convert.ToInt32 returns the actual decimal value of the char and not the number 2.  The following will work:  int bar = Convert.ToInt32(new string(foo, 1));   int.parse only works on strings as well.    Is there no native function in C# to go from a char to int without making it a string?  I know this is trivial but it just seems odd that there's nothing native to directly make the conversion.
25904
As a follow-up to :  From what I've seen, this should work as expected:  void greet(){   char c[] = "Hello";   greetWith(c);   return; }   but this will cause undefined behavior:  char *greet(){    char c[] = "Hello";   return c; }   If I'm right, what's the best way to fix the second greet function? In an embedded environment? On a desktop?
81943
How does one parse an integer to string(char* || char[]) in C? Is there an equivalent to the Integer.parseInt(String) method from Java in C?
14769
I need to concatenate two String arrays in Java.  void f(String[] first, String[] second) {     String[] both = ??? }   What is the easiest way to do this?
33306
Hey! I was looking at this code at   I noticed that in some situations they used hex numbers, like in line 134:  for (j = 1; val &amp;&amp; j &lt;= 0x80; j &lt;&lt;= 1, q++)   Now why would they use the 0x80? I am not that good with hex but I found an online hex to decimal and it gave me 128 for 0x80.  Also before line 134, on line 114 they have this:  small_n = (n &amp; 0xffff0000) == 0;   The hex to decimal gave me 4294901760 for that hex number. So here in this line they are making a bit AND and comparing the result to 0??  Why not just use the number? Can anyone please explain and please do give examples of other situations.  Also I have seen large lines of code where it's just hex numbers and never really understood why :(
7083
I need to  an object to . I'm using . Is there a "standard" way to do this?  My specific situation: I have an array defined as shown below:  var countries = new Array(); countries[0] = 'ga'; countries[1] = 'cd'; ...   and I need to turn this into a string to pass to  like this:  $.ajax({     type: "POST",     url: "Concessions.aspx/GetConcessions",     data: "{'countries':['ga','cd']}", ...
8464
How do you concatenate characters in java? Concatenating strings would only require a + between the strings, but concatenating chars using + will change the value of the char into ascii and hence giving a numerical output. I want to do System.out.println(char1+char2+char3... and create a String word like this.  I could do   System.out.print(char1); System.out.print(char2); System.out.print(char3);   But, this will only get me the characters in 1 line. I need it as a string. Any help would be appreciated.  Thanks
116230
We have a user provided string that may contain unicode characters, and we want the robot to type that string.  How do you convert a string into keyCodes that the robot will use? How do you do it so it is also java version independant (1.3 -> 1.6)?  What we have working for "ascii" chars is  //char c = nextChar(); //char c = 'a'; // this works, and so does 'A' char c = 'á'; // this doesn't, and neither does 'Ă' Robot robot = new Robot(); KeyStroke key = KeyStroke.getKeyStroke("pressed " + Character.toUpperCase(c) ); if( null != key ) {   // should only have to worry about case with standard characters   if (Character.isUpperCase(c))   {     robot.keyPress(KeyEvent.VK_SHIFT);   }    robot.keyPress(key.getKeyCode());   robot.keyRelease(key.getKeyCode());    if (Character.isUpperCase(c))   {     robot.keyRelease(KeyEvent.VK_SHIFT);   } }
54515
I want to implement numbering scheme like Microsoft Word uses for numbering.  first one gets = A,next is  B, next is C, .... then AA, then AB,....and so on.  as shown below   A        B  C  .   .  AA  AB  AC  .  .  AAA  AAB  ....   '=>' here means converted to.  some examples:       1 =&gt; A 26 =&gt; Z 27 =&gt; AA 52 =&gt; AZ 53 =&gt; BA   and heres the code for it:     var convertToNumberingScheme = function(n){         var x = n-1,             r26 = x.toString(26),             baseCharCode = "A".charCodeAt(0);          var arr = r26.split(''),             len = arr.length;          var newArr =arr.map(function(val,i){             val = parseInt(val,26);              if( (i === 0) &amp;&amp; ( len &gt; 1)){                 val = val-1;             }              return String.fromCharCode(baseCharCode + val);         });         return newArr.join('');     }   It seems to work fine, but any ideas if there are some potential bugs or ways to  optimize this.
83249
Very similar to , except for Java.  What is the recommended way of encoding strings for an XML output in Java. The strings might contain characters like "&amp;", "&lt;", etc.
28473
How do I get the  value of a character as an int in ?
118343
I'd like to display the binary (or hexadecimal) representation of a floating point number.  I know how to convert by hand (using the method ), but I'm interested in seeing code samples that do the same.  Although I'm particularly interested in the C++ and Java solutions, I wonder if any languages make it particularly easy so I'm making this language agnostic.  I'd love to see some solutions in other languages.  EDIT: I've gotten good coverage of C, C++, C#, and Java.  Are there any alternative-language gurus out there who want to add to the list?