CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Java >  J2SE / 基础类

k=(k>0)?(p++, k=0):k+1;

楼主onestab()2003-02-03 03:07:58 在 Java / J2SE / 基础类 提问

以上代码是什么意思?  
  摘自《Java与面向对象程序设计教程》印旻  
  p55,p56,p58,p61 问题点数:20、回复次数:4Top

1 楼onestab()回复于 2003-02-03 03:18:44 得分 0

excerpt   from   Thinking   in   java   2e:  
  The   comma   operator  
  Earlier   in   this   chapter   I   stated   that   the   comma   operator   (not   the   comma   separator,   which   is   used   to   separate   definitions   and   function   arguments)   has   only   one   use   in   Java:   in   the   control   expression   of   a   for   loop.   In   both   the   initialization   and   step   portions   of   the   control   expression   you   can   have   a   number   of   statements   separated   by   commas,   and   those   statements   will   be   evaluated   sequentially.    
  //:   c03:CommaOperator.java  
  public   class   CommaOperator   {  
      public   static   void   main(String[]   args)   {  
          for(int   i   =   1,   j   =   i   +   10;   i   <   5;  
                  i++,   j   =   i   *   2)   {  
              System.out.println("i=   "   +   i   +   "   j=   "   +   j);  
          }  
      }  
  }   ///:~  
  >>>   在   ?   :   中也可以用   ","   吗?   k=(k>0)?(p++,   k=0):k+1;Top

2 楼danceflash(Wine)回复于 2003-02-03 03:22:59 得分 10

好像是错的吧  
  记得Java中的逗号运算符只能用于"for"循环Top

3 楼danceflash(Wine)回复于 2003-02-03 03:23:47 得分 5

呵呵~~~  
  楼上好快的说^_^Top

4 楼marf_cn(吗啡)回复于 2003-02-03 15:02:48 得分 5

是啊Top

相关问题

  • P
  • 关于EPSON的ESC/P-K指令的问题?
  • &*p
  • Pirm is P!
  • int **p
  • A& operator=(A &p);
  • <p></p>的问题
  • int* p=malloc(100); p+=10; free(p);
  • what's the difference between (*p)[4] and *p[4]
  • unsigned char *p;sizeof(*p)问题

关键词

  • commas
  • separated

得分解答快速导航

  • 帖主:onestab
  • danceflash
  • danceflash
  • marf_cn

相关链接

  • CSDN Java频道
  • Java类图书
  • Java类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo