All about java wrapper classes
The classes which are used to convert the string value (Actually numeric) into it's respective data type, are called as wrapper classes.


Classes
  • Integer
  • Float
  • Character
  • Long
  • Short
  • Byte
  • Boolean
  • Double
And there respective static parsing methods are :
  • parseInt()
  • parsefloat()
  • parselong()
  • parseShort()
  • parseDouble()
  • parseByte()
  • parseChar()
  • parseBoolean()


Integer.parseInt()

It converts the string value into integer type.

float.parsefloat()

It converts the string value into float type.


Write a program to print addition of two numbers passed through command line.

class Add1
{
 public static void main(String args[])
 {
  int n=args.length;
  if(n>1)
  {
  int a,b,c;
  a=Integer.parseInt(args[0]);
  b=Integer.parseInt(args[1]);
  c=a+b;
  System.out.println("Addition is "+c);
  }
         else
   System.out.println("Please enter two arguments");
 }
}

How To Run ?
javac Add1.java
java Add1 10 30
Axact

Narendra

Hello, everyone! I am Narendra Bagul founder of Javanotes9. First of all thank you for visiting my blog. Hope you all like my java notes as well. I'm young part time blogger and a Computer Engineering student. I started blogging as a hobby. Now here I'm sharing my little acquired knowledge about my favorite programming language JAVA.

Post A Comment: