fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.nio.charset.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. //String symbol = new String( new int[] {0x1F780}, 0, 1 );
  14. String symbol = "\ud83d\udf80";
  15. System.out.println( symbol );
  16. byte[] bytes = symbol.getBytes( StandardCharsets.UTF_8 );
  17.  
  18. System.out.println( Arrays.toString( bytes ) );
  19. for( byte b : bytes ) {
  20. System.out.printf( "%02x", b );
  21. }
  22. System.out.println();
  23.  
  24. String newString = new String( bytes, StandardCharsets.UTF_8 );
  25. System.out.println( newString );
  26.  
  27. System.out.printf( "%x%n", newString.codePointAt(0) );
  28. }
  29. }
Success #stdin #stdout 0.09s 2841600KB
stdin
Standard input is empty
stdout
🞀
[-16, -97, -98, -128]
f09f9e80
🞀
1f780