2014-03-31 54 views
0

我在eclipse中有这个java代码。当我运行它时,我认为我应该在Eclipse底部的控制台中找回一些东西。不是这种情况。 eclipse底部的控制台是空白的。未在Eclipse中打印到控制台的Java代码

package com.veggiedogtreats.javacode; 

public class doobeedoobeedo { 

/** 
* @param args 
*/ 
public static void main(String[] args) { 
    int x = 1; 
    while (x < 0) { 
     System.out.println("Doo"); 
     System.out.println("Bee"); 
     x = x + 1; 
    } 
    if (x == 2) { 
     System.out.print("Do"); 


    } 

} 

} 
+1

何时'1'小于'0'? –

+1

明天1日是明天:) – JohnnyAW

回答

2

你有while循环设置为x < 0,它应该是x > 0。你有它的方式,它永远不会进入while循环

+0

真棒,这是...感谢帮助noobie出:) – PolarisUser

0

你的程序只打印到控制台当x小于零,当x是2

X总有1

int x = 1; // x is 1 
while (x < 0) { // 1 is not less than zero, doesn't enter the loop 
    System.out.println("Doo"); 
    System.out.println("Bee"); 
    x = x + 1; 
} 

if (x == 2) { // 1 is not two, doesn't enter the if 
    System.out.print("Do"); 
} 

也许你想要的东西,像一个值这样的:

while (x < 0) { .... } 
0

您的条件不满足,因此sysout语句不执行。请更改初始值x或条件,以便至少执行一次执行语句sysout

0

这两个条件语句都不成立。 1不小于零或等于2.

2

您的状态是错误的。它应该是while (x > 0)而不是while (x < 0)