CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Threaded View

  1. #1
    Join Date
    Aug 2009
    Posts
    52

    Finding number position

    Hi i have a problem here im reading 2 int values f and digit from a user and i want to count the position of the number he input in a reverse order starting from 1. i Kept getting -1 from this. I think the problem is because of INT mismatch with String?Or can i use indexOfSubList? how can i implement it

    Code:
    public static int pos(int f, int digit){
          
             StringBuffer phrase = new StringBuffer(f);
             phrase.reverse();
             String x=Integer.toString(digit);
             int firstoccur = phrase.indexOf(x); // find where the Digit x first occurs
            
             return firstoccur;
    Last edited by hugo84; September 12th, 2009 at 08:19 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured