Please note that the variable *** i *** has changed to 0-7.
Color.java
public class Color{
public static void main(String[] args){
//Change the font color
for(int i=0;i<8;i++){
//int i =0;
System.out.println("\u001b[00;3"+i+"m esc[00;3"+i+" \u001b[00m");
}
//Change the background color
for(int i=0;i<8;i++){
System.out.println("\u001b[00;4"+i+"m esc[00;4"+i+" \u001b[00m");
}
}
}
Output result
You can color it like this
Also, if you use it frequently, I think it's a good idea to make stock first like this.
Color.java
public class Color{
public static void main(String[] args){
String red = "\u001b[00;31m";
String green = "\u001b[00;32m";
String yellow = "\u001b[00;33m";
String purple = "\u001b[00;34m";
String pink = "\u001b[00;35m";
String cyan = "\u001b[00;36m";
String end = "\u001b[00m";
String[] names = new String[]{red,green,yellow,purple,pink,cyan};
for(int i=0; i< names.length; i++){
System.out.println(names[i]+"hello"+end);
}
}
}
Command line
Recommended Posts