0
Java program to check if number has ten digit or not
Hi i don't how to check a number's digit in java i'd appriciate your help. Thanks
3 Respuestas
+ 7
int x = 1234567890;
String s = Integer.toString(x);
System.out.print(s.length()==10?true:false);
//so we get some ints
//we then convert int to string using toString method thats inside class Integer
//as string is an object it has methods so we access one of its methods called length
//we then check to see if the returned value equals 10 if yes print true else print false
+ 7
String input = "6282526282";
int pos = 2;
System.out.print(Integer.valueOf(input.charAt(pos)+"")*pos);
/* so this would be starting from index 0
8*2 = 16
*/
0
assume that we received 10 digit number. How can we multiply the numbers digit by its position.
for example
1234567893
1 position is 10
i want to do this for all digits