Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Quick quick Java question

  1. Sep 30, 2005 #1
    :redface: Is there a way to convert a character representation of an integer into an integer (with integer representation :rolleyes:)?
    *for example (I'll add 8 to a certain digit in an integer),

    String nmbr; //where I enter a number
    int pst; //an integer representing the position of that digit in the number

    System.out.println( nmbr.charAt(pst) + 8 );

    Obviously, I cannot add a character and an integer. Thus, I change to:

    System.out.println( Integer.parseInt(String.valueOf(nmbr.charAt(pst))) + 8 );

    and it works, no compiling errors.

    *However, is there a shorter way of converting a character representation of an integer to...well, an integer? :frown: Shorter than typing out:

    " Integer.parseInt(String.valueOf(nmbr.charAt(pst))) " ?
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted

Similar Threads for Quick quick Java Date
Moore's law is quickly becoming obsolete, what will they to next? Mar 5, 2011
Calculators HP50G Quick Question Jul 18, 2010
Calculators HP 50g Calculator [2 Quick Questions] Apr 30, 2010
Calculators TI-89 quick question Sep 12, 2007
Calculators HP 50g - Quick, simple question Mar 2, 2007