+ 1
I need a help visually in android studio pls help me out......
17 Answers
+ 4
Provide a proper description about your problem.
+ 2
sir am getting issue while getting sum of 10 digits number in android studio
the app crashes when i ask it to add 10 digits but it adds 9 digit properly so thats my issue
+ 2
What type of error it has, can you show your log report.
I think it could be Nullpointer error. You need assign your EditText first.
+ 1
Please Clarify your question and let's find out the error ?
+ 1
Post the code
+ 1
public class SumofDigits
{
int sum=0;
public int sum(long num)
{
if(num!=0)
{
sum+=num%10;
num/=10;
sum(num);
}
return sum;
}
}
$##this is the class and and using it with main
+ 1
public void Addbtn (){
try {
String number = editTextphonenum.getText().toString();
int newnum = new Integer(number).intValue();
long n;
SumofDigits sumofDigits = new SumofDigits();
int sc = (int) newnum;
n = sc;
Toast.makeText(this, "total is"+sumofDigits.sum(sc), Toast.LENGTH_SHORT).show();
}catch (Exception e){
Toast.makeText(this, "please put some value to add", Toast.LENGTH_SHORT).show();
}
}
#$#$am using that class here
+ 1
No add it to youre code bits
+ 1
the error is pointing here (int newnum = new Integer(number).intValue();)
+ 1
DeepesHackeR could you put the code in the code bits it will be much clearer
+ 1
sir isuue is with android studio
+ 1
see i saved to codebits
+ 1
Ok let me see it
+ 1
Maybe you make it private, I can't find it
+ 1
now u can get it
+ 1
This code only is not valid in Android studio, may be if you have all code could you give me
+ 1
Public class SumofDigis
{