fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.regex.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. private static int chopDecimals(String s) {
  12. //String ss = " ";
  13. if (s.charAt(s.length()-2) == '.' && s.charAt(s.length()-1) == '0'){
  14. s = s.substring(0,s.length()-2);
  15. }
  16.  
  17. int converted = Integer.parseInt(s);
  18. return converted;
  19. }
  20.  
  21. public static void main (String[] args) throws java.lang.Exception
  22. {
  23.  
  24. String s = String.valueOf(1.0);
  25. System.out.println(s);
  26. int converted = chopDecimals(s);
  27. System.out.println(s);
  28. System.out.println(converted);
  29.  
  30. }
  31. }
Success #stdin #stdout 0.06s 380160KB
stdin
Standard input is empty
stdout
1.0
1.0
1