Title: Getting each different numbers separately and examining them in java
Tags: java
Question: I am new to java and i want to make a program where i want to get the integers the user has input, and look at what different numbers they are. and move them around as well as add stuff between them.
For example:
Enter number
User input: 123456
after that i want to see what the first number is, which is 1 or what the third number is which is 3. i want to be able to get those different information. and play around with them, for example add the sixth and the first number and print it out for the user.
Which technique in java allows me to do that, what is the name so i could study it more.
if there is a video online teaching that, it would also be great.
Thanks.
ps. i know the basics, i dont need to know how to do the second part playing with the numbers i just dont know how to tell what the first or second number in the lists of number is.
Comment: You can use the `%` operator and \ to get individual numbers and insert them into an int array.


Here is another answer: Try the below code :You are taking an integer input and converting it into a string
public class InputNumberProgram {
public static void main(String[] args) {
Integer i = 5678;
// Convert your input to a string
String s = Integer.toString(i);
System.out.println("Length of input:" + s.length());  System.out.println(Integer.parseInt(s.valueOf(s.charAt(0)))+Integer.parseInt(s.valueOf(s.charAt(1))));
}

Here is another answer: If you read it as a String and do what you want with String methods
For example you have String number. To get i-th symbol you can use number.charAt(i)
Comment for this answer: What if the input is an `int`. You should mention the use of the `String.valueOf`

Here is another answer: Eg: 123456
Convert the int to string keep the int also
1) String.valueOf(number)
2) Integer.toString(number)
get the length of the string using String.length();
the if you want the 3rd number
Use the int value for the following operation
Eg: 123456 (3rd number 3) Since you have the length of the string you know what will be the divisor
divide using 10 * 10 * 10 this will 123456/1000 = 123
Then % it with 10 always you can put these within a methos to get any position

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 3, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:11/24/13', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<java>', 'Title': 'Getting each different numbers separately and examining them in java', 'ViewCount': 48, 'id': 20172712, 'user_AboutMe': None, 'user_AccountId': 3630583.0, 'user_DisplayName': 'user3026873', 'user_Reputation': 1.0, 'user_Views': 2.0, 'user_id': 3026873.0}}