Sep 05

se static method java.lang.Integer.valueOf(), or create java.lang.Integer instance directly using constructor.

String s = "123";
try
{
   Integer i = Integer.valueOf(s);

   // or alternatively, create instance directly

   Integer i2 = new Integer(s);
}
catch (java.lang.NumberFormatException ex)
{
   // s is not an integer
}

written by objects \\ tags: , ,


Leave a Reply

You must be logged in to post a comment.