fork download
  1. public class Main {
  2. public static void main(String[] args) {
  3. // ANSI escape codes for colored output
  4. String redText = "\u001B[31m"; // Red color code
  5. String blueBackground = "\u001B[44m"; // Blue background color code
  6. String resetColor = "\u001B[0m"; // Reset color code
  7.  
  8. // Print "Hello, World" in red with a blue background
  9. System.out.println(blueBackground + redText + "\n\n Hello, World \n\n" + resetColor);
  10.  
  11. // Print additional details
  12. System.out.println("This is a simple Java program running on an online compiler!");
  13. System.out.println("It demonstrates how to use ANSI escape codes for colored text output in the console.");
  14.  
  15. // Display the color key
  16. System.out.println("\nColor Key:");
  17. System.out.println(redText + "Red Text" + resetColor);
  18. System.out.println(blueBackground + "Blue Background" + resetColor);
  19. }
  20. }
  21.  
Success #stdin #stdout 0.15s 60064KB
stdin
Standard input is empty
stdout


   Hello, World   


This is a simple Java program running on an online compiler!
It demonstrates how to use ANSI escape codes for colored text output in the console.

Color Key:
Red Text
Blue Background