Friday, 30 January 2015

Java Program To Convert String To Integer and Integer to String

public class StringToInteger
{
 public static void main(String[] args) 
 {
  String s = "2015";
  
  int i = Integer.parseInt(s);
  
  System.out.println(i);          //Output : 2015
 }
}

public class IntegerToString
{
 public static void main(String[] args) 
 {
  int i = 2015;
  
  String s = Integer.toString(i);
  
  System.out.println(s);     //Output : 2015
 }
}

No comments:

Post a Comment