fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. System.out.println( "Face with Tears of Joy: " + Character.toString( 128_514 ) ) ;
  13.  
  14. byte[] bytesA = Character.toString( 128_514 ).getBytes( "UTF8" );
  15. byte[] bytesB = new String( Character.toChars( 128_514 ) ).getBytes( "UTF8" );
  16.  
  17. System.out.println( "Arrays.toString( bytesA ) = " + Arrays.toString( bytesA ) );
  18. System.out.println( "Arrays.toString( bytesB ) = " + Arrays.toString( bytesB ) );
  19.  
  20. // bytesA = {byte[4]@823} [-16, -97, -104, -126]
  21. // bytesB = {byte[4]@824} [-16, -97, -104, -126]
  22.  
  23. }
  24. }
Success #stdin #stdout 0.12s 35948KB
stdin
Standard input is empty
stdout
Face with Tears of Joy: 😂
Arrays.toString( bytesA ) = [-16, -97, -104, -126]
Arrays.toString( bytesB ) = [-16, -97, -104, -126]