当前位置:   article > 正文

Java初学者错误1:incompatible types: boolean cannot be converted to int_incompatible types: statement cannot be converted

incompatible types: statement cannot be converted to preparedstatement
  1. private static int get_wx_inx(String str) {
  2. boolean equalsIgnoreCase = str.equalsIgnoreCase("0");
  3. int equalsIgnoreCase2 = str.equalsIgnoreCase("1");
  4. if (str.equalsIgnoreCase("2")) {
  5. equalsIgnoreCase2 = true;
  6. }
  7. if (str.equalsIgnoreCase("3")) {
  8. equalsIgnoreCase2 = 3;
  9. }
  10. return str.equalsIgnoreCase("4") ? 4 : equalsIgnoreCase2;
  11. }

JDK版本问题,如果仍要使用该版本,则更正为:

  1. private static int get_wx_inx(String str) {
  2. if(str.equalsIgnoreCase("0")) {
  3. return 0;
  4. } else if(str.equalsIgnoreCase("1")) {
  5. return 1;
  6. }else if(str.equalsIgnoreCase("2")) {
  7. return 2;
  8. } else if(str.equalsIgnoreCase("3")) {
  9. return 3;
  10. } else if(str.equalsIgnoreCase("4")) {
  11. return 4;
  12. } else {
  13. return 0;// write default return here. If every condition goes false then this default will be return.
  14. }
  15. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/199129
推荐阅读
相关标签
  

闽ICP备14008679号