日期:2014-05-20 浏览次数:20804 次
package test;
public class TestPrint {
public static void main(String[] args) {
String str = "*";
String singleStr = "*";
for (int i = 0; i < 5; i++) {
System.out.println(str);
str = str + singleStr;
}
}
}
------解决方案--------------------
public class PrintDemo {
public static void main(String args[]) {
for(int i=0;i<5;i++){
for(int j=0;j<=i;j++){
System.out.print("*");
}
System.out.println("");
}
}
}
------解决方案--------------------
public static void main(String[] args) {
String s = "*";
for (int i = 0; i < 5; i++) {
System.out.println(s);
s=s+"*";
}
}
------解决方案--------------------
public class PrintAsterisk {
/**
* @param args
*/
public static void main(String[] args) {
for(int i = 0; i < 5; i++){
for(int j = 0; j <= i; j++)
System.out.print("*");
System.out.println("");
}
}
}
------解决方案--------------------
LZ 一定要自己写,不会也要试着写。写几个就能发现差不多的规律,初学不难。不然到最后你会发现,自己动手能力很差,看着可能懂,但是写不出来。
我自己就吃过这方面的亏