why my code is wrong

lighteen 2003-12-14 01:44:19
I want to write a code that can draw triangle
public class A{
public static void main(String [] args){

for(int i=0; i<2; i++)
{
for(int a=2; a<2-i; a++)
System.out.print(" ");
for(int b=0; b<2i+1; b++)
System.out.print("*");
System.out.println();
}
}
}

but it shows me: why?
H:\A.java:8: ';' expected
for(int b=0; b<2i+1; b++)
^
1 error

Tool completed with exit code 1
...全文
58 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
pleonheart 2003-12-14
  • 打赏
  • 举报
回复
for(int b=0; b<2*i+1; b++)

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧