if(条件){System.out.println("hello")}else{System.out.println("wrold")}同时输出hello wrold
package com.thread; public class second extends Thread{ public static void main(String[] args) { /** * if(条件){ * System.out.println("hello"); * }else{ * System.out.println("wrold"); * } * 输出:hello wrold */ //方法一 // if(System.out.printf("hello").equals("")){ // System.out.println("hello"); // }else{ // System.out.println(" world"); // } //方法二:用多线程 if(new Thread(){ { this.start(); //在一个静态块中启动一个线程 } @Override public void run() { System.out.println(" wrold"); } }.isAlive()){ System.out.print("hello"); }else{ System.out.println("wrold"); } } }