黑马程序员技术交流社区

标题: 一道有趣的题 [打印本页]

作者: 刘_鑫    时间: 2013-7-2 07:25
标题: 一道有趣的题
package ifjg;
public class Tex {
public static void main(String[] args) {
  if(___________){
   System.out.println("world");
  }
  else{
   System.out.println("hello");
  }
}
}
只能在if(_____)里面写代码,如何让输出结果是“hello world”?

作者: 贾永长    时间: 2013-7-2 08:19
这样挺OK的!{:soso_e189:}
  1. public class Tex
  2. {
  3.         public static void main(String[] args)
  4.     {
  5.                 if(System.out.append("hello ") != null)
  6.                 {
  7.                         System.out.println("world");
  8.                 }
  9.                 else
  10.                 {
  11.                         System.out.println("hello");
  12.                 }
  13.     }
  14. }
复制代码

作者: 王广亚    时间: 2013-7-2 08:23
有意思,但做不出来,看起来违背了语法。想知道答案
作者: j816326    时间: 2013-7-2 10:23
贾永长 发表于 2013-7-2 08:19
这样挺OK的!

高人这样都行啊
作者: 刘_鑫    时间: 2013-7-2 13:00
{:soso_e129:} 哈哈
作者: 黑马龙子    时间: 2013-7-8 19:32
在if的()括号中填写为:System.out.append("hello")!=null 即可。




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2