点击上方“Java后端技术之路”,选择“置顶或者星标”
与你一起成长
上图来源网络,如有侵权请联系
你还在不敢表白吗?来来来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");
}
}
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、效果如图:
这怎么可能那倒我们呢是吧,来搞起来!!!
1、查看有哪些颜色 color -help
2、改变颜色 color fc
3、输入心形
4、卡卡卡 我再给你个颜色
6666666666666666,祝大家告白成功。
面试精选
MQ消息队列常见面试题详解
Redis常见面试题详解
备战2020,十四道Mybatis常见面试题!!!
十二道Spring常见面试题
Spring 常见面试题一,助你2020 ,come on
微服务面试题 - Spring Cloud
备战2020面试题,Java面试题下(锁、AQS、线程池)