Java: Comparing ints and Strings - Performance

后端 未结 3 869
孤街浪徒
孤街浪徒 2020-12-18 19:33

I have a String and an int, lets say: String str = \"12345\"; and int num = 12345;. What is the fastest way of seeing if they are the same, s

3条回答
  •  醉梦人生
    2020-12-18 19:43

    Guess you might also be able to use this to compare........

    int p = 1234;
    String Int = "1234";
    String string = String.valueOf(p);
    System.out.println(string + Int);
    System.out.println(string.equals(Int));
    code here
    

提交回复
热议问题