zoukankan      html  css  js  c++  java
  • java中的int转化为char型并输出【java】

    之前用语句

    int b = 2;

    char c = (char) b;

    System.out.println( c );

    会无法输出数字2,而是像一个比“口”字还小的一个框,

    正确的方法(但不一定是最优的)

       1:  public class menglei {
       2:      public static void main(String[] args ){
       3:          
       4:          int b = 4;
       5:          String s = String.valueOf(b);
       6:          char c = s.charAt(0);
       7:          System.out.println(c);
       8:          
       9:      }
      10:  }

    问题就得到解决了微笑

    转载文章请注明出处: http://www.cnblogs.com/menglei/
  • 相关阅读:
    BSGS算法(大步小步算法)
    UVA-11426【GCD
    UVA-1637【Double Patience】(概率dp)
    UVA-11174【Stand in a Line】
    About
    51nod 1355 斐波那契的最小公倍数
    CodeForces
    CodeForces
    CodeForces
    CodeForces 901C Bipartite Segments
  • 原文地址:https://www.cnblogs.com/menglei/p/2662762.html
Copyright © 2011-2022 走看看