Current Position:Home > Finding the position of an integer in a string

Finding the position of an integer in a string

Update:10-11Source: network consolidation
Advertisement
I haven't done much Java programming for the past 3 months, but I'm trying to get back into it now, but I'm having some trouble. I'm trying to break up a string of integers, to store each individual integer in an array.
So, if I had something like 132412344, a for loop would put them all into separate arrays.
I know that there is a charAt() function, but is there something like that for integers?

The Best Answer

Advertisement
Do you know whether every single character in the string is an integer?
If it is, then toCharArray will get you the array. Then you could loop through it to parse each character into an int. You can use Character.digit to do that.
I doubt that there's any method that automatically splits a string and returns the integers represented by the characters in a string. It seems like too specialized a method. But I could be wrong.
  • Finding the position of an integer in a string Update:10-11

    I haven't done much Java programming for the past 3 months, but I'm trying to get back into it now, but I'm having some trouble. I'm trying to break up a string of integers, to store each individual integer in an array. So, if I had something like 13

  • Find first occurence of an integer in a string Update:11-30

    Hi all, I have a number of strings which go something like "MBNA Flow 12a" and I want to separate the integer from the rest of the string so I can parse it, sort the strings into some sort of order according to their integer, and then put it all

  • Market requires versionCode to be set to a positive 32-bit integer in AndroidManifest.xml Update:11-30

    I have built an application on flash builder Buritto  using the tutorial of " Christophe Coenraets"  building an EmployeeDirectory  and everything worked fine while debugging it in virtual environment but when I try to upload it to the andoid ma

  • Is it possible to get the position of a charcter from a string ? Update:10-11

    Hi ! Is it possible to get the position of a charcter from a string ? Example: @VAR contains the following text "ABCDEFGHIJKLM" I'am seaching for FGH, it start on pos. 6 en ends on pos 8. How can I get these numbers 6 and 8 ? So, I can use them

  • 2 parts: 1) integer array to string 2) string out to a jTextField Update:11-30

    I am completely new to Java and Netbeans, but I'm writing my 1st application that takes a "hex" character input from a jTextField, then converts it to an "binary" integer array. I then do a lot of bit manipulation, and generate a new &

  • Need help in finding the position of a SubString in a String Update:11-30

    Hi All, I have a VARCHAR2 column in my table which has data similar to '152-425-3265-8-5623-45'. I want to find the position of the numbers in the column. For example: If i give 8 - query should return me 4. If i give 425 - query should return me 2.

  • To get the position of the characters in the string in sql Update:11-30

    hi all, I need to get the position of the characters in the sql , the string like this '10101110111010111' , is it possible to get the answer like this pos char 1 1 2 0 3 1 4 0 and so on . Thanks in advance .select level pos,substr(:your_string,level

  • Change integer value to string? Update:11-30

    Hi all, I was wondering if it is possible to change an integer value to a string. I saw in this forum that a string can be changed to an integer using parseInt and I was wondering if there is a similar method for going the other way. Regards.try this

  • Are Vector Integer and Vector String different types? Update:11-30

    Maybe I am missing something. Are Vector <String> and Vector <Integer> different types? Can I have to methods of the same name with arguments of these types? That would be the point of method overloading. Appearently not. The following code do

  • How do we convert an integer to a string? Update:10-11

    thanks!It might be somewhat less efificient because it uses a StringBuffer (and its append method, then a toString), that is, it constructs one object more. public class a { public String tos(int i) { return ""+i; }javap -c -private a Compiled f