java爱心代码跳动教程
时间: 2023-11-08 09:05:57 浏览: 129
以下是Java实现爱心跳动的代码:
```
public class HeartBeat {
public static void main(String[] args) throws InterruptedException {
String heart = " ❤️ ";
String blank = " ";
String[] lines = new String[]{
" " + heart + " " + heart + " ",
" " + heart + " " + heart + " ", heart + " " + heart,
heart + blank + heart,
" " + heart + blank + heart + " ",
" " + heart + blank + heart + " ",
" " + heart + blank + " ",
" " + heart + " "
};
while (true) {
for (String line : lines) {
System.out.println(line);
}
Thread.sleep(500);
System.out.print("\033[H\033[2J");
System.out.flush();
}
}
}
```
阅读全文