Hi ,
I want to get a String from command line argument and add the values.
class Sample
{
public static void main(String args[])throws IOException
{
String Given_Id=args[0];//Getting input
int Add=0;;
int Store=0;
System.out.println("The length of the String is "+Given_Id.length());//Calculating length
for(int i=1;i<Given_Id.length();i++)
{
Add=Given_Id.charAt(i);
Store=Store+Add;//Adding values
}
System.out.println("The total is "+Store);
}
}
But it is displaying wrong output.
Given Value :p1234
Omitting P character in for loop and adding the balance values.
But not getting the output it displays some junk characters.
Expected Output:
10
Occured Output:
Junk characters
can any one help me out .
Thank you,
With Regards.
Prem