黑马程序员技术交流社区

标题: 代码补全打印想要结果 [打印本页]

作者: 赵佳    时间: 2013-7-5 22:05
标题: 代码补全打印想要结果
本帖最后由 杜光 于 2013-7-6 08:00 编辑

public class Text {
public static void main(String[] args) {
  if(___________){
   System.out.println("world");
  }
  else{
   System.out.println("hello");
  }
}
}
只能在if(_____)里面写代码,如何让输出结果是“hello world”?
作者: 刘_鑫    时间: 2013-7-5 22:13
楼主试试这样写
package test;
public class NewDemo {
public static void main(String[] args) {

         if (System.out.append("hello ") != null) {
             System.out.println("world");
         } else {
             System.out.println("hello");
         }
     }
}




作者: 宋智超    时间: 2013-7-5 22:15
  1. public class Text {
  2. public static void main(String[] args) {
  3. if(System.out.printf("hello ")!=null) {
  4. System.out.println("world");
  5. }
  6. else{
  7. System.out.println("hello");
  8. }
  9. }
  10. }
复制代码

作者: lipingan0520    时间: 2013-7-7 09:35
  1. public class Text11
  2. {
  3.         public static void main(String[] args)
  4.         {
  5.                 {
  6.                         System.out.print("Hello ");   //构造代码块
  7.                 }

  8.                 if(new Text11() != null)
  9.                 {
  10.                         System.out.println("World");
  11.                 }
  12.                 else
  13.                 {
  14.                         System.out.println("Hello");
  15.                 }
  16.         }       
  17. }
复制代码





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