2012年7月11日 星期三

Integer.parseInt (字串轉整數)

Integer.parseInt : 為字串轉整數

java.lang
Class Integer

java.lang.Object
  extended by java.lang.Number
      extended by java.lang.Integer
All Implemented Interfaces:
SerializableComparable<Integer>

Method Summary
static intparseInt(String s)
          Parses the string argument as a signed decimal integer.

Example:

public class app1_4
{
public static void main(String args[])
{
int n1 = Integer.parseInt(args[0]);
int n2 = Integer.parseInt(args[1]);
System.out.println("n1 +  n2 = " + (n1 + n2));
}
}


沒有留言:

張貼留言