-1
i tried to use Answers which already were on stackOverflow but couldn't figure it out

here is my code , how can i print emojis on eclipse console public class SipirtAnimal {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

          Scanner kb = new Scanner(System.in);
          String name = kb.next().toLowerCase();
           System.out.println("================================================");
           System.out.println("YOUR SPIRIT ANIMALS ACCORDING TO YOUR NAME ARE ");
           for(int i=0; i<name.length(); i++) {
               switch(name.charAt(i)) {
               case 'a':{
                   String grinningFace = "\xF0\x9F\x98\x81";
                  System.out.print(b);
               }
           }
        
        
    }
    }
}
coding_girl
  • 81
  • 2
  • 4

1 Answers1

0

tl;dr

String s = "";  // Paste the emoji character into source code.

Paste emoji character

Paste the emoji character into your source code.

UTF-8

I suggest you set your project and IDE to use UTF-8 encoding in your Java source files. This enables handling all 143,859 characters defined by Unicode 13 including all the emoji.

If using Apache Maven, set a property <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>; or something similar in Gradle or Ivy.

String s = "";
System.out.println( s ) ;

See this code run live at IdeOne.com.

Character.toString( codePoint )

Alternatively, pass the decimal number of the code point for that character to Character.toString.

String y = Character.toString( 128_512 );
System.out.println( y ) ;

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154