點擊上方“Java後端技術之路”,選擇“置頂或者星標”
與你一起成長
上圖來源網絡,如有侵權請聯繫
【早上的我,看到朋友圈已經開始炫技了,起來擼一份簡單的表白代碼】
一、IDEA下表白
你還在不敢表白嗎?來來來pine教你用java 表白,來燥起來。
love方法:用於輸出心形
redAppend方法:用於改變顏色(顏色方法在IDEA下會生效,其他IDE沒測試,CMD命令下不生效)。
package com.pine.cloud;
/**
* 520 心形輸出
* @author anzy
* @version 1.0
* @date 2020/5/20 9:43
**/
public class My520 {
public static void main(String[] args) {
System.out.println(love("*"));
color();
}
public static String love(String input) {
int[] array = {0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 4, 5, 2, 3, 4, 1, 0, 1,
0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
StringBuffer sb = new StringBuffer();
for (int i = 0; i < array.length; i++) {
if (i % 7 == 0)
sb.append(" \n");
if (array[i] == 0)
sb.append(" ");
else if (array[i] == 4)
sb.append(" ");
else if (array[i] == 5)
redAppend(sb," I " );
else if (array[i] == 2)
redAppend(sb, "Lvoe ");
else if (array[i] == 3)
redAppend(sb, "You" );
else
redAppend(sb.append(" "),input );
}
return sb.toString();
}
public static void redAppend(StringBuffer sb,String str){
// 適用於IDE環境下改變顏色,不適用與cmd窗口,cmd窗口通過color -help 然後color 47 這樣去改變
sb.append("\033[31;4m" + str + "\033[0m");
// sb.append(str);
}
public static void color() {
System.out.println("\033[30;4m" + "my color" + "\033[0m");
System.out.println("\033[31;4m" + "my color" + "\033[0m");
System.out.println("\033[32;4m" + "my color" + "\033[0m");
System.out.println("\033[33;4m" + "my color" + "\033[0m");
System.out.println("\033[34;4m" + "my color" + "\033[0m");
System.out.println("\033[35;4m" + "my color" + "\033[0m");
System.out.println("\033[36;4m" + "my color" + "\033[0m");
System.out.println("\033[37;4m" + "my color" + "\033[0m");
System.out.println("\033[40;31;4m" + "my color" + "\033[0m");
System.out.println("\033[41;32;4m" + "my color" + "\033[0m");
System.out.println("\033[42;33;4m" + "my color" + "\033[0m");
System.out.println("\033[43;34;4m" + "my color" + "\033[0m");
System.out.println("\033[44;35;4m" + "my color" + "\033[0m");
System.out.println("\033[45;36;4m" + "my color" + "\033[0m");
System.out.println("\033[46;37;4m" + "my color" + "\033[0m");
System.out.println("\033[47;4m" + "my color" + "\033[0m");
}
}
二、CMD命令下表白
1、java編譯爲class
javac D:\workspace\IdeaProjects\xiangxue\spring-cloud-demo\demo-other\src\main\java\com\pine\cloud\My520.java
2、運行class文件,需要注意的是運行時要到根包下例如我的就是java目錄下。具體原因大家可以翻閱一下資料,今天主題520哈哈哈哈。
Java com.pine.cloud.My520
3、效果如圖:
三、你女友說CMD下心我要紅紅的背景
這怎麼可能那倒我們呢是吧,來搞起來!!!
1、查看有哪些顏色 color -help
2、改變顏色 color fc
3、輸入心形
4、卡卡卡 我再給你個顏色
6666666666666666,祝大家告白成功。
面試精選