java problem

    技术2025-11-18  18

    1.

    http://topic.csdn.net/u/20080920/22/c89b653a-8c84-4157-8c73-b6ca091e96df.html

    int b1; int count = -1; int a1 = (int)(Math.random()*26)+97; System.out.println(+a1); //int b1 = System.in.read(); do {  System.out.println("please input character:");     b1 = System.in.read();  // System.in.skip(2);  count++;  System.out.println(+count); }while (b1!=a1);

     

     

    你是在windows操作系统上测试的吧?在windows上,换行的时候不止一个字符哦,是/r/n两个字符,就是0x0D和0x0A。你跳过前一个,没跳过后一个,0x0A是多少呢?16进制,刚好是10进制的数字10。这就是为什么你一直读到10的原因。

     

     

    2.Cannot make a static reference to the non-static method XXXX from the type Main

    谨记了,静态方法只能调用静态方法,main调用的方法一定要加static

     

    3.http://zhidao.baidu.com/question/96252026.html

    java中如何将char数组转化为String?

    最新回复(0)