java语言爱心代码动态
时间: 2023-10-23 21:14:02 浏览: 126
以下是Java语言实现爱心代码的动态效果:
```java
public class Heart {
public static void main(String[] args) throws InterruptedException {
String heart = " ❤️ ";
String blank = " ";
String[] lines = new String[]{
" * * * * * * * * ",
" * * * * ",
" * * * * ",
" * * * * ",
" * *",
" * *",
" * *",
" * * ",
" * * ",
" * * ",
" * * ",
" * * ",
" * * ",
" * * ",
" * * ",
" * * ", " * * ",
" * * ",
" * * ",
" * "
};
while (true) {
for (String line : lines) {
System.out.print(line.replace("*", heart).replace(" ", blank));
Thread.sleep(50);
}
System.out.println();
}
}
}
```
阅读全文