Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 27th, 2012  |  syntax: None  |  size: 0.27 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How can I extract the first 4 digits from an int? (Java)
  2. String str = "1234567890";
  3. int fullInt = Integer.parseInt(str);
  4. String first4char = str.substring(0,4);
  5. int intForFirst4Char = Integer.parseInt(first4char);
  6.        
  7. Integer.parseInt(myIntegerString.substring(0, 4))