乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      線程“main”中的異常java.lang.NumberFormatException:對于輸入字符串:“t1”?

       印度阿三17 2019-08-24

      我是Java的新手,我在這里遇到了這個問題.我會發(fā)布鏈接并記住,這里的其他類似問題對我沒有幫助,因?yàn)槲矣胁煌拇a,因此我在這里創(chuàng)建了這個帳戶.

      碼:

      package secret.package.guys;
      
      import java.util.Scanner;
      
      public class NewClass {
      public static void main(String[] args) {
      
          System.out.println("Number: ");
          Scanner scanner = new Scanner(System.in); 
          String data=scanner.nextLine(); 
          System.out.println(data);
      
      
          int a = 0; 
      
          while(a < 6) {
              System.out.println(a);
              a  ; 
              }
      
          if (a > 6){ 
              System.out.println("SAFE SPACE");
      
      
          } else {
              System.out.println("Get in the Safe Space");
              System.out.println("PERSON has entered the Safe Space. Safe Space closes instantly.");
          }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
          String s = new String("Old marks: ");
          String t = new String("5.5"); 
          String u = new String("4"); 
          String v = new String("3"); 
          String w = new String("2.5"); 
          String x = new String("6.0"); 
          String y = new String("5.2"); 
          String z = new String("4"); 
      
          String t1 = t.replaceAll("5.5", "6");
          String u1 = u.replaceAll("4", "4");
          String v1 = v.replaceAll("3", "5");
          String w1 = w.replaceAll("2.5", "3");
          String x1 = x.replaceAll("6.0", "2");
          String y1 = y.replaceAll("5.2", "1.8");
          String z1 = z.replaceAll("4", "4.4");
          System.out.println("New: "   s   " "   t1   " "   u1   " "   v1   " "   w1   " " 
            x1   " "   y1   " "   z1);
          System.out.println("Enter new marks: ");
      
          int foo = Integer.parseInt("t1"); 
          int foo1 = Integer.parseInt("u1"); 
          int foo2 = Integer.parseInt("v1"); 
          int foo3 = Integer.parseInt("w1"); 
          int foo4 = Integer.parseInt("x1"); 
          int foo5 = Integer.parseInt("y1"); 
          int foo6 = Integer.parseInt("z1"); 
      
          System.out.println("foo1   foo2   foo3   foo4   foo5   foo6");
      
      }   
      

      }

      解決方法:

      您必須在String變量的值上調(diào)用parseInt,而不是在變量名稱上調(diào)用.

      例如,

      int foo = Integer.parseInt("t1"); 
      

      應(yīng)該

      int foo = Integer.parseInt(t1); 
      

      這只有在t1包含整數(shù)的String表示時才會起作用(這意味著parseInt(z1)和parseInt(y1)仍會失敗,因?yàn)檫@些字符串不包含整數(shù)).

      來源:https://www./content-1-405001.html

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約