N天前,我从编程中国上闲来无事,抄了一段代码,如下
public class HelloWorld {
public static void main(String[] args) {
System.out.println("我学JAVA");
System.out.println();
// 练习一下循环的使用
for (int i=1; i<=20; i++) {
System.out.printf("我爱编程 %d 次\n", i);
}
System.out.printf("\n\n绘制一个心形图案:");
float x, y;
for (y = (float)1.5; y > -1.5; y -= 0.1) {
for (x = (float)-1.5; x < 1.5; x += 0.05) {
float a = x * x + y * y - 1;
if ((a * a * a - x * x * y * y * y) <= 0.0) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}
然后. . . .
你文件建错了,代码需要在.java文件中写 兄弟
自己建一个class类 把中间的代码粘过去不久行了嘛?
我都不知道该怎么跟你解释,你这错的也太离谱了。
你把文件名改成HelloWorld.java
......